Table of Contents
Defines a set of widgets useful for constructing a user menu.
This was made primarily because in some cases in the MineSight® Grail library we need to allow for delayed construction of widgets, but still provide the ability to make an advanced layout. See GPanelApp definemenus method for an example of this concept.
An example of defining a menu structure can be found in the grail.widgets.gpanelapp module. But a small example is illustrated here.
Suppose we want to make a menu bar with a "File" and "Help" menu. The File menu will contain a "Open", "Save", "Save As..." and "Exit" options. The "Help" menu will contain the "About" and "Help" options. Pretty standard menu structure.
We will start with the imports,
Then we will define our call back functions, for now we will simply leave them empty.
These can be filled in at a later time.
Next, we will define our menu items as a list of GMenuItem objects,
Now, lets define our menus, they will each contain the items we just finished writing out.
Yes, one of those rare cases of limited typing. Soak it up.
All right, back to the building the menu, now the next step is to construct the menu bar.
The root will be the parent application window and we will have packed the menubar into the top right corner.
The Menu widgets comprise of the following components.
Defines a menu that takes a list of menuitems.
Returns the character that is suppose to have an underline or None if no character is supposed to be underlined.
Note
This does not return the index.
Warning
DEPRECATED (as of MineSight® Grail v1.1).
This function currently does nothing.
Defines a Menubar.
An item on a menu.
For example the "Open" item on the "File" menu.
To specify the letter to make a hot key use the underline. So for example, "_Open" would make the "O" a hot key as a GMenuItem.
Note
Some important items to note with regards to this widget,
- getcallback()
- Returns the callback function.
- getname()
- Returns the name of the item.
- gettype()
- Returns the type of the item. Currently only 'command' or 'separator'.
- getunderline()
- Returns the index to the character underlined.
- isseparator()
- No longer does anything useful.
Specialized GMenuItem.
Basically uses a name equal '-' as a type of "separator". This makes it easier to type,
than,