Inheritance diagram for wx.MenuItem:
A menu item represents an item in a menu. Note that you usually don’t have to deal with it directly as wx.Menu methods usually construct an object of this class for you.
Note
Please note that the methods related to fonts and bitmaps are currently only implemented for Windows and GTK+.
See also
Constructs a wx.MenuItem object.
Menu items can be standard, or “stock menu items”, or custom. For the standard menu items (such as commands to open a file, exit the program and so on) it is enough to specify just the stock ID and leave text and helpString empty. In fact, leaving at least text empty for the stock menu items is strongly recommended as they will have appearance and keyboard interface (including standard accelerators) familiar to the user.
For the custom (non-stock) menu items, text must be specified and while helpString may be left empty, it’s recommended to pass the item description (which is automatically shown by the library in the status bar when the menu item is selected) in this parameter.
Finally note that you can e.g. use a stock menu label without using its stock help string:
# use all stock properties:
helpMenu.Append(wx.ID_ABOUT)
# use the stock label and the stock accelerator but not the stock help string:
helpMenu.Append(wx.ID_ABOUT, "", "My custom help string")
# use all stock properties except for the bitmap:
mymenu = wx.MenuItem(helpMenu, wxID_ABOUT)
mymenu.SetBitmap(wx.ArtProvider.GetBitmap(wx.ART_WARNING))
helpMenu.AppendItem(mymenu)
That is, stock properties are set independently one from the other.
Parameters:
Returns:
Checks or unchecks the menu item.
Parameters:
Note
Note that this only works when the item is already appended to a menu.
Enables or disables the menu item.
Parameters:
Returns the background colour associated with the menu item (Windows only).
Returns:
Returns the checked or unchecked bitmap (Windows only).
Parameters:
Returns:
Returns the help string associated with the menu item.
Returns:
string
Returns the menu item identifier.
Returns:
int
Returns the text associated with the menu item including any accelerator characters that were passed to the constructor or SetItemLabel.
Returns:
string
See also
Returns the text associated with the menu item, without any accelerator characters.
Returns:
string
See also
Returns the item kind, one of wx.ITEM_SEPARATOR, wx.ITEM_NORMAL, wx.ITEM_CHECK or wx.ITEM_RADIO.
Returns:
int
Returns the text associated with the menu item without any accelerator characters it might contain.
Parameters:
Returns:
string
Warning
This function is deprecated in favour of GetItemLabelText.
See also
Strips all accelerator characters and mnemonics from the given text. For example:
menuItem.GetLabelFromText("&Hello\tCtrl-H")
will return just "Hello".
Parameters:
Returns:
string
Warning
This function is deprecated; please use GetLabelText instead.
Strips all accelerator characters and mnemonics from the given text. For example:
menuItem.GetLabelText("&Hello\tCtrl-H")
will return just "Hello".
Parameters:
Returns:
string
See also
Gets the width of the menu item checkmark bitmap (Windows only).
Returns:
int
Returns the menu this menu item is in, or None if this menu item is not attached.
Returns:
Returns the submenu associated with the menu item, or None if there isn’t one.
Returns:
Returns the text associated with the menu item, such as it was passed to the wx.MenuItem constructor, i.e. with any accelerator characters it may contain.
Returns:
string
Warning
This function is deprecated in favour of GetItemLabel.
See also
Returns the text colour associated with the menu item (Windows only).
Returns:
Returns True if the item is checkable.
Returns:
bool
Returns True if the item is checked.
Returns:
bool
Returns True if the item is enabled.
Returns:
bool
Returns True if the item is a separator.
Returns:
bool
Returns True if the item is a submenu.
Returns:
bool
Parameters:
Sets the background colour associated with the menu item (Windows only).
Parameters:
Sets the bitmap for the menu item (Windows and GTK+ only). It is equivalent to SetBitmaps (bmp, wx.NullBitmap).
Parameters:
Sets the checked/unchecked bitmaps for the menu item (Windows only).
The first bitmap is also used as the single bitmap for uncheckable menu items.
Parameters:
Sets the menu item as checkable.
Parameters:
Sets the font associated with the menu item (Windows only).
Parameters:
Sets the help string.
Parameters:
Sets the menu item id.
Parameters:
Sets the label associated with the menu item.
Parameters:
Sets the menu item kind, which may be one of wx.ITEM_SEPARATOR, wx.ITEM_NORMAL, wx.ITEM_CHECK or wx.ITEM_RADIO.
Parameters:
Sets the width of the menu item checkmark bitmap (Windows only).
Parameters:
Parameters:
Sets the text associated with the menu item.
Parameters:
Warning
This function is deprecated in favour of SetItemLabel.
Sets the text colour associated with the menu item (Windows only).
Parameters: