GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing docs.wxpython.org — wx.Menu — wxPython 4.3.2 Docs
|
Constructs a wx.Menu object. |
|
Adds a menu item. |
|
Adds a checkable item to the end of the menu. |
|
Adds a radio item to the end of the menu. |
|
Adds a separator to the end of the menu. |
|
Adds the given submenu to this menu. |
|
Inserts a break in a menu, causing the next appended item to appear in a new column. |
|
Checks or unchecks the menu item. |
|
Deletes the menu item from the menu. |
|
Deletes the menu item from the menu. |
|
Enables or disables (greys out) a menu item. |
|
Finds the menu item object associated with the given menu item identifier and, optionally, the position of the item in the menu. |
|
Finds the menu id for a menu item string. |
|
FindItemById(id) . MenuItem |
|
Returns the wx.MenuItem given a position in the menu. |
|
Returns the help string associated with a menu item. |
|
Returns a menu item label. |
|
Returns a menu item label, without any of the original mnemonics and accelerators. |
|
Returns the number of items in the menu. |
|
Returns the list of items in the menu. |
|
Returns the title of the menu. |
|
Inserts the given item before the position pos. |
|
Inserts a checkable item at the given position. |
|
Inserts a radio item at the given position. |
|
Inserts a separator at the given position. |
|
Determines whether a menu item is checked. |
|
Determines whether a menu item is enabled. |
|
Inserts the given item at position 0, i.e. before all the other existing items. |
|
Inserts a checkable item at position 0. |
|
Inserts a radio item at position 0. |
|
Inserts a separator at position 0. |
|
Removes the menu item from the menu but doesn’t delete the associated C++ object. |
|
Sets an item’s help string. |
|
Sets the label of a menu item. |
|
Sets the title of the menu. |
|
Update the state of all menu items, recursively, by generating |
Properties Summary¶See |
|
See |
|
See |
|
See |
|
See |
Class API¶Possible constructors:
Menu() -> None Menu(style) -> None Menu(title, style=0) -> None
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).
__init__ (self)
Constructs a wx.Menu object.
None
__init__ (self, style)
Constructs a wx.Menu object.
style (long) – If set to wx.MENU_TEAROFF, the menu will be detachable (wxGTK and QT only).
None
__init__ (self, title, style=0)
Constructs a wx.Menu object with a title.
title (string) – Title at the top of the menu (not always supported).
style (long) – If set to wx.MENU_TEAROFF, the menu will be detachable (wxGTK and QT only).
None
Append (self, id, item=’’, helpString=’’, kind=ITEM_NORMAL)
Adds a menu item.
id (int) – The menu command identifier. See Window IDs for more information about IDs (same considerations apply to both window and menu item IDs).
item (string) – The string to appear on the menu item. See wx.MenuItem.SetItemLabel for more details.
helpString (string) – An optional help string associated with the item. By default, the handler for the wxEVT_MENU_HIGHLIGHT event displays this string in the status line.
kind (ItemKind) – May be ITEM_SEPARATOR , ITEM_NORMAL , ITEM_CHECK or ITEM_RADIO .
self.fileMenu.Append(ID_NEW_FILE, "&New file\tCTRL+N", "Creates a XYZ document")
or even better for stock menu items (see MenuItem.__init__ ):
self.fileMenu.Append(wx.ID_NEW, "", "Creates a XYZ document")
Note
This command can be used after the menu has been shown, as well as on initial creation of a menu or menubar.
See also
AppendSeparator , AppendCheckItem , AppendRadioItem , AppendSubMenu , Insert , SetLabel , GetHelpString , SetHelpString , wx.MenuItem
Append (self, id, item, subMenu, helpString=’’)
Adds a submenu.
id (int) – The menu command identifier.
item (string) – The string to appear on the menu item.
subMenu (wx.Menu) – Pull-right submenu.
helpString (string) – An optional help string associated with the item. By default, the handler for the wxEVT_MENU_HIGHLIGHT event displays this string in the status line.
Deprecated
This function is deprecated, use AppendSubMenu instead.
See also
AppendSeparator , AppendCheckItem , AppendRadioItem , AppendSubMenu , Insert , SetLabel , GetHelpString , SetHelpString , wx.MenuItem
Append (self, menuItem)
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.
menuItem (wx.MenuItem) – A menuitem object. It will be owned by the wx.Menu object after this function is called, so do not delete it yourself.
Note
See the remarks for the other Append overloads.
See also
AppendSeparator , AppendCheckItem , AppendRadioItem , AppendSubMenu , Insert , SetLabel , GetHelpString , SetHelpString , wx.MenuItem
Adds a checkable item to the end of the menu.
id (int)
item (string)
help (string)
See also
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.
id (int)
item (string)
help (string)
See also
Adds a separator to the end of the menu.
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.
submenu (wx.Menu)
text (string)
help (string)
menubar (wx.MenuBar)
None
Inserts a break in a menu, causing the next appended item to appear in a new column.
This function only actually inserts a break in wxMSW and does nothing under the other platforms.
None
Checks or unchecks the menu item.
id (int) – The menu item identifier.
check (bool) – If True, the item will be checked, otherwise it will be unchecked.
None
See also
Delete (self, id)
Deletes the menu item from the menu.
If the item is a submenu, it will not be deleted. Use Destroy if you want to delete a submenu.
id (int) – Id of the menu item to be deleted.
bool
Delete (self, item)
Deletes the menu item from the menu.
If the item is a submenu, it will not be deleted. Use Destroy if you want to delete a submenu.
item (wx.MenuItem) – Menu item to be deleted.
bool
DestroyItem (self, id)
Deletes the menu item 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).
id (int) – Id of the menu item to be deleted.
bool
DestroyItem (self, item)
Deletes the menu item 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).
item (wx.MenuItem) – Menu item to be deleted.
bool
None
Enables or disables (greys out) a menu item.
id (int) – The menu item identifier.
enable (bool) – True to enable the menu item, False to disable it.
None
See also
Finds the menu item object associated with the given menu item identifier and, optionally, the position of the item in the menu.
Unlike FindItem , this function doesn’t recurse but only looks at the direct children of this menu.
id (int) – The identifier of the menu item to find.
Tuple[MenuItem, int]
Menu item object or nullptr if not found.
FindItem (self, itemString)
Finds the menu id for a menu item string.
itemString (string) – Menu item string to find.
int
Menu item identifier, or wx.NOT_FOUND if none is found.
Note
Any special menu codes are stripped out of source and target strings before matching.
FindItem (self, id)
Finds the menu item object associated with the given menu item identifier and, optionally, the (sub)menu it belongs to.
id (int) – Menu item identifier.
Tuple[MenuItem, Menu]
Menu item object or nullptr if none is found.
FindItemById(id) . MenuItem
Finds the menu item object associated with the given menu item identifier.
Returns the wx.MenuItem given a position in the menu.
position (int)
Returns the help string associated with a menu item.
id (int) – The menu item identifier.
str
The help string, or the empty string if there is no help string or the item was not found.
See also
Returns a menu item label.
id (int) – The menu item identifier.
str
The item label, or the empty string if the item was not found.
See also
Returns a menu item label, without any of the original mnemonics and accelerators.
id (int) – The menu item identifier.
str
The item label, or the empty string if the item was not found.
Returns the number of items in the menu.
int
Returns the list of items in the menu.
MenuItemList is a pseudo-template list class containing wx.MenuItem pointers, see List.
MenuItemList
int
Insert (self, pos, menuItem)
Inserts the given item before the position pos.
Inserting the item at position GetMenuItemCount is the same as appending it.
pos (int)
menuItem (wx.MenuItem)
Insert (self, pos, id, item=’’, helpString=’’, kind=ITEM_NORMAL)
Inserts the given item before the position pos.
Inserting the item at position GetMenuItemCount is the same as appending it.
pos (int)
id (int)
item (string)
helpString (string)
kind (ItemKind)
Insert (self, pos, id, text, submenu, help=’’)
Inserts the given submenu before the position pos.
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.
pos (int)
id (int)
text (string)
submenu (wx.Menu)
help (string)
See also
Inserts a checkable item at the given position.
pos (int)
id (int)
item (string)
helpString (string)
See also
Inserts a radio item at the given position.
pos (int)
id (int)
item (string)
helpString (string)
See also
Inserts a separator at the given position.
pos (int)
See also
bool
Determines whether a menu item is checked.
id (int) – The menu item identifier.
bool
True if the menu item is checked, False otherwise.
See also
Determines whether a menu item is enabled.
id (int) – The menu item identifier.
bool
True if the menu item is enabled, False otherwise.
See also
Prepend (self, menuItem)
Inserts the given item at position 0, i.e. before all the other existing items.
menuItem (wx.MenuItem)
Prepend (self, id, item=’’, helpString=’’, kind=ITEM_NORMAL)
Inserts the given item at position 0, i.e. before all the other existing items.
id (int)
item (string)
helpString (string)
kind (ItemKind)
Prepend (self, id, text, subMenu, help=’’)
Inserts the given submenu at position 0.
id (int)
text (string)
subMenu (wx.Menu)
help (string)
See also
Inserts a checkable item at position 0.
id (int)
item (string)
helpString (string)
See also
Inserts a radio item at position 0.
id (int)
item (string)
helpString (string)
See also
Inserts a separator at position 0.
See also
Remove (self, id)
Removes the menu item from the menu but doesn’t delete the associated C++ object.
This allows you to reuse the same item later by adding it back to the menu (especially useful with submenus).
id (int) – The identifier of the menu item to remove.
A pointer to the item which was detached from the menu.
Remove (self, item)
Removes the menu item from the menu but doesn’t delete the associated C++ object.
This allows you to reuse the same item later by adding it back to the menu (especially useful with submenus).
item (wx.MenuItem) – The menu item to remove.
A pointer to the item which was detached from the menu.
Sets an item’s help string.
id (int) – The menu item identifier.
helpString (string) – The help string to set.
None
See also
Sets the label of a menu item.
id (int) – The menu item identifier.
label (string) – The menu item label to set.
None
Sets the title of the menu.
title (string) – The title to set.
None
Note
Notice that you can only call this method directly for the popup menus, to change the title of a menu that is part of a menu bar you need to use wx.MenuBar.SetMenuLabel .
See also
Update the state of all menu items, recursively, by generating wxEVT_UPDATE_UI events for them.
This is an internal wxWidgets function and shouldn’t normally be called from outside of the library. If it is called, source argument should not be used, it is deprecated and exists only for backwards compatibility.
source (wx.EvtHandler)
None
See GetInvokingWindow and SetInvokingWindow
See GetMenuItemCount
See GetMenuItems