Inheritance diagram for wx.Menu:
A menu is a popup (or pull down) list of items, one of which may be selected before the menu goes away (clicking elsewhere dismisses the menu). Menus may be used to construct either menu bars or popup menus.
A menu item has an integer ID associated with it which can be used to identify the selection, or to change the menu item in some way. A menu item with a special identifier -1 is a separator item and doesn’t have an associated command but just makes a separator line appear in the menu.
Note
Please note that wx.ID_ABOUT and wx.ID_EXIT are predefined by wxWidgets and have a special meaning since entries using these IDs will be taken out of the normal menus under MacOS X and will be inserted into the system menu (following the appropriate MacOS X interface guideline). On PalmOS wx.ID_EXIT is disabled according to Palm OS Companion guidelines.
Menu items may be either normal items, check items or radio items. Normal items don’t have any special properties while the check items have a boolean flag associated to them and they show a checkmark in the menu when the flag is set. wxWidgets automatically toggles the flag value when the item is clicked and its value may be retrieved using either IsChecked method of wx.Menu or wx.MenuBar itself or by using wx.Event.IsChecked when you get the menu notification for the item in question.
The radio items are similar to the check items except that all the other items in the same radio group are unchecked when a radio item is checked. The radio group is formed by a contiguous range of radio items, i.e. it starts at the first item of this kind and ends with the first item of a different kind (or the end of the menu).
Note
Notice that because the radio groups are defined in terms of the item positions inserting or removing the items in the menu containing the radio items risks to not work correctly.
Note
Finally note that radio items are not supported under Motif.
See also
Construct a wx.Menu object.
Parameters:
Returns:
Adds a menu item object. This is the most generic variant of Append() method because it may be used for both items (including separators) and submenus and because you can also specify various extra properties of a menu item this way, such as bitmaps and fonts.
This command can be used after the menu has been shown, as well as on initial creation of a menu or menubar.
The string string for the normal menu items (not submenus or separators) may include the accelerator which can be used to activate the menu item from keyboard. The accelerator string follows the item label and is separated from it by a TAB stringacter ('\t'). Its general syntax is any combination of CTRL, ALT and SHIFT strings (case doesn’t matter) separated by either '-' or '+' stringacters and followed by the accelerator itself.
The accelerator may be any alphanumeric string character, any function key (from F1 to F12) or one of the special string characters listed in the table below (again, case doesn’t matter):
Key | Description |
---|---|
DEL or DELETE | Delete key |
INS or INSERT | Insert key |
ENTER or RETURN | Enter key |
PGUP | PageUp key |
PGDN | PageDown key |
LEFT | Left cursor arrow key |
RIGHT | Right cursor arrow key |
UP | Up cursor arrow key |
DOWN | Down cursor arrow key |
HOME | Home key |
END | End key |
SPACE | Space |
TAB | Tab key |
ESC or ESCAPE | Escape key (Windows only) |
Parameters:
Returns:
See also
AppendSeparator, AppendCheckItem, AppendRadioItem, AppendSubMenu, Insert, SetLabel, GetHelpString, SetHelpString, wx.MenuItem
Adds a checkable item to the end of the menu.
Parameters:
Returns:
See also
Appends a wx.MenuItem to the current menu.
Parameters:
Returns:
Appends a submenu to the current menu.
Parameters:
Returns:
Adds a radio item to the end of the menu. All consequent radio items form a group and when an item in the group is checked, all the others are automatically unchecked.
Parameters:
Returns:
See also
Adds a separator to the end of the menu.
Returns:
See also
Adds the given submenu to this menu. text is the text shown in the menu for it and help is the help string shown in the status bar when the submenu item is selected.
Parameters:
Returns:
Parameters:
Checks or unchecks the menu item.
Parameters:
See also
Deletes the menu item from the menu.
If the item is a submenu, it will not be deleted. Use DestroyId if you want to delete a submenu.
Parameters:
Deletes the menu item from the menu.
If the item is a submenu, it will not be deleted. Use DestroyItem if you want to delete a submenu.
Parameters:
Returns:
bool
See also
Deletes the menu item with id id from the menu.
If the item is a submenu, it will be deleted. Use Remove if you want to keep the submenu (for example, to reuse it later).
Parameters:
Returns:
bool
Deletes the menu item from the menu.
If the item is a submenu, it will be deleted. Use RemoveItem if you want to keep the submenu (for example, to reuse it later).
Parameters:
Returns:
bool
Enables or disables (greys out) a menu item.
Parameters:
See also
Finds the menu item object associated with the given menu item.
Parameters:
Returns:
int
Note
Any special menu codes are stripped out of source and target strings before matching.
Finds the menu item object associated with the given menu item identifier.
Parameters:
Returns:
Returns the wx.MenuItem given a position in the menu.
Parameters:
Returns:
Returns the help string associated with a menu item.
Parameters:
Returns:
string
See also
Returns a menu item label, including any mnemonics and accelerators.
Parameters:
Returns:
string
See also
Returns a menu item label, without any of the original mnemonics and accelerators.
Parameters:
Returns:
string
Returns the number of items in the menu.
Returns:
long
Returns the list of items in the menu. wx.MenuItemList is a pseudo-template list class containing wx.MenuItem pointers.
Returns:
wx.MenuItemList
Returns the title of the menu.
Returns:
string
Note
This is relevant only to popup menus, use wx.MenuBar.GetMenuLabel for the menus in the menubar.
See also
Inserts the given item before the position pos.
Inserting the item at position GetMenuItemCount is the same as appending it.
Parameters:
Returns:
Inserts a checkable item at the given position.
Parameters:
Returns:
See also
Inserts the given menu item at the specified position.
Parameters:
Returns:
Parameters:
Returns:
Inserts a radio item at the given position.
Parameters:
Returns:
See also
Inserts a separator at the given position.
Parameters:
Returns:
See also
Determines whether a menu item is checked.
Parameters:
Returns:
bool
See also
Determines whether a menu item is enabled.
Parameters:
Returns:
bool
See also
Prepend the given menu item with id id at position 0.
Parameters:
Returns:
Inserts a checkable item at position 0.
Parameters:
Returns:
See also
Prepends a menu item at position 0.
Parameters:
Returns:
Parameters:
Returns:
Inserts a radio item at position 0.
Parameters:
Returns:
See also
Inserts a separator at position 0.
Returns:
See also
Removes the menu item from the menu but doesn’t delete the associated C++ object. This allows to reuse the same item later by adding it back to the menu (especially useful with submenus).
Parameters:
Returns:
Removes the menu item from the menu but doesn’t delete the associated C++ object. This allows to reuse the same item later by adding it back to the menu (especially useful with submenus).
Parameters:
Returns:
Parameters:
Sets an item’s help string.
Parameters:
See also
Sets the label of a menu item.
Parameters:
Sets the title of the menu.
Parameters:
Note
This is relevant only to popup menus, use wx.MenuBar.SetLabelTop for the menus in the menubar.
See also
Sends events to source (or owning window if None) to update the menu UI. This is called just before the menu is popped up with wx.Window.PopupMenu, but the application may call it at other times if required.
Parameters: