This class is not intended for direct use, but through subclasses. Subclasses should implement at least the following methods: addSeparator() insertSeperator(before) addAction(text,action) insertAction(before,text,action) addMenu(text,menu) insertMenu(before,text,menu)
QtGui.Menu and QtGui.MenuBar provide these methods.
The BaseMenu class has this constructor:
title='AMenu',parent=None,before=None,items=None) |
This is a hierarchical menu that keeps a list of its item names and actions.
BaseMenu objects have the following methods:
text) |
Text normalization removes all '&' characters and converts to lower case.
item) |
item is either one of the menu's item texts, or one of its values. This method guarantees that the return value is either the corresponding Action, or None.
before=None) |
menu,before=None) |
action,before=None) |
str,val,before=None) |
items,before=None) |
Each item is a tuple of two to five elements: Text, Action, [ Icon, ShortCut, ToolTip ].
Item text is the text that will be displayed in the menu. It will be stored in a normalized way: all lower case and with '&' removed.
Action can be any of the following: - a Python function or instance method : it will be called when the item is selected, - a string with the name of a function/method, - a list of Menu Items: a popup Menu will be created that will appear when the item is selected, - None : this will create a separator item with no action.
Icon is the name of one of the icons in the installed icondir. ShortCut is an optional key combination to select the item. Tooltip is a popup help string.
If before is given, it specifies the text OR the action of one of the items in the menu: the new items will be inserted before that one.