2.3 DirectMenuItem
Menu widget dedicated for typical application menus with clickable entries and sub-menu entries.
from DirectGuiExtension.DirectMenuItem import DirectMenuItem, DirectMenuItemEntry, DirectMenuItemSubMenu
# create menu structure
itemList = [
DirectMenuItemEntry("Save", showBrowser, [False]),
DirectMenuItemEntry("Load", showBrowser, [True]),
DirectMenuItemSubMenu("Recent >", [
DirectMenuItemEntry("Item A", print, ["Item A"]),
DirectMenuItemEntry("Item B", print, ["Item B"]),
DirectMenuItemEntry("Item C", print, ["Item C"])
]),
DirectMenuItemEntry("Quit", quit, [])]
# create the actual menu
fileMenu = DirectMenuItem(text="File", scale=0.1, item_relief=1, items=itemList)
items: List
A list of DirectMenuItemEntry
and DirectMenuItemSubMenu
instances. See below for more information on them.
popupMenuLocation: One of DirectGuiGlobals.LEFT, RIGHT, ABOVE or BELOW The opening direction of the popup menu. Default is below. Note: Those values may not be defined by default in the DGG and can be defined as follow:
DGG.LEFT = "left"
DGG.RIGHT = "right"
DGG.ABOVE = "above"
DGG.BELOW = "below"
highlightColor: Four-state color value
Background color to use to highlight popup menu items
itemFrameColor: Four-state color value
Background color of unhighlighted menu items
isSubMenu: Boolean
Determines if this is a sub menu. This is used internally and may be ignored.
parentMenu: other menu
The parent menu to this sub-menu. This is used internally and may be ignored.
The default clickable menu entry
text
The text displayed on the item
command
The command to be called when the item is clicked
extraArgs=None
Extra arguments passed to the command call
A sub menu which can contain a list of menu items and further sub-menu items
text
The text displayed on the item
items
List of DirectMenuItemEntry
or DirectMenuItemSubMenu
instances