<- previous index next ->
The "Menu Bar" and drop down menus are the most common today. You could do your own menus, yet you will probably want to use the large amount of code provided by a GUI tool kit. This lecture will cover the details often hidden by most GUI tool kits. You may need to understand how menus are created in case you have to work around a bug or problem in the tool kit you are using. The richest toolkit for menus is Motif. (Linux/Unix/macOS) Close behind is proprietary Microsoft Windows C++ classes. Next comes Java Swing/Swing2. The weakest we will look at is OpenGL with GLUT. Yet, strong by getting FLTK, the Fast Light ToolKit from www.fltk.org Defacto standardization makes some design issues obvious. The "File" is on the left of the "Menu Bar". The "Help" is on the right, or rightmost, of the "Menu Bar". Using defacto standard names helps average users. Using names that mean something to you are best for an application you write for your own use. Example programs to be covered are: In X Windows using Motif, observe windows, widgets and buttons being created, callbacks assigned and functions to handle callbacks. The executable is w4 . w4a.c In OpenGL, a mouse click is used to popdown the menu. Note that OpenGL requires sub menus to be created before the main menu, the opposite order of Motif or Java. w4gl.c Not able to capture open menu and get graphic. In Java using Swing, observe menu creation then menu item creation, action listeners and functions to handle actions. W4frame.java For the more complex example, Spline Tutorial, download and compile: (note package myjava; and import myjava.*; fix to suit) I have this in my 'myjava' directory and use java myjava.SplineFrame In Python using tk, simple menu and callbacks. w4tk.py3 Note that other windows are opened for tutorial information. The 'parameter' pull down menu uses radio buttons. The mouse is used for both menu selection and graphics. In Python using tk, a rotating dot, must be run to observe This is an example of moving an object. w5tk.py3 source code Spline example in Java, reading files and math Spline.java SplineFrame.java Then you need the *.txt files that are read at execution time: SplineHelp.txt SplineAbout.txt SplineAlgorithm.txt SplineEvaluate.txt SplineIntegrate.txt Clicking on menu bar 'Algorithm' (no 'File' items needed) Clicking on menu bar 'Help' (Note that pull down menu can go outside the main window in Java.) To run demo I have my flash drive in the USB port and do commands: F: setup # runs setup.bat to set path and classpath cd myjava # where this demo is located java myjava.SplineFrame # I used 'package' The Lecture outline was: Show demo's. Quickly survey code. Explain how menubar or other features are created. Explain how menus are created in menubars. Explain how menu items are created in menus. Explain how callbacks are coded to act when a menu item is selected. Show where to put code that responds to a menu item select. Can be in-line code if short and simple. Use function call to handle long or complex actions. Very repetitive, much to remember, copy, cut and paste to suit. HW2 is assigned
<- previous index next ->
Many web sites on Java GUI, AWT, Swing, etc. Many web sites on Python wx, tk, qt, etc.