wx.lib.agw.flatmenu.FlatMenuItem¶
A class that represents an item in a menu.
Class Hierarchy¶
Methods Summary¶
Default class constructor. |
|
Checks or unchecks the menu item. |
|
Enables or disables a menu item. |
|
Returns the accelerator entry associated to this menu item. |
|
Returns the accelerator string. |
|
Returns the normal bitmap associated to the menu item or |
|
Returns the context menu associated with this item (if any). |
|
Returns the disabled bitmap associated to the menu item or |
|
Returns this |
|
Returns the menu item height, in pixels. |
|
Returns the item help string. |
|
Returns the hot bitmap associated to the menu item or |
|
Returns the item id. |
|
Returns the menu item kind, can be one of |
|
Returns the menu item label (without the accelerator if it is part of the string). |
|
Returns the item long help string (displayed in the parent frame |
|
Returns the parent menu. |
|
Returns the shortcut char for this menu item. |
|
Returns the menu item client rectangle. |
|
Returns the item short help string (displayed in the tool’s tooltip). |
|
Returns the sub-menu of this menu item (if any). |
|
Gets the bitmap that should be used based on the item state. |
|
Returns the text associated with the menu item including the accelerator. |
|
Returns this |
|
Returns |
|
Returns whether an item is checked or not. |
|
Returns whether an item is enabled or not. |
|
Returns |
|
Returns |
|
Returns whether an item is shown or not. |
|
Returns whether an item is a sub-menu or not. |
|
Assigns a context menu to this item. |
|
Sets the menu item disabled bitmap. |
|
Sets the |
|
Sets the menu item help string. |
|
Sets the menu item hot bitmap. |
|
Sets the label text for this item from the text (excluding the accelerator). |
|
Sets the item long help string (displayed in the parent frame |
|
Sets the menu item parent menu. |
|
Links the current menu item with the main |
|
Sets the menu item normal bitmap. |
|
Sets the menu item client rectangle. |
|
Sets the menu item sub-menu. |
|
Sets the text for this menu item (including accelerators). |
|
Sets the |
|
Actually shows/hides the menu item. |
Class API¶
- class FlatMenuItem(object)¶
A class that represents an item in a menu.
Methods¶
- __init__(self, parent, id=wx.ID_SEPARATOR, label='', helpString='', kind=wx.ITEM_NORMAL, subMenu=None, normalBmp=wx.NullBitmap, disabledBmp=wx.NullBitmap, hotBmp=wx.NullBitmap)¶
Default class constructor.
- Parameters:
parent – menu that the menu item belongs to, an instance of
FlatMenu
;id (integer) – the menu item identifier;
label (string) – text for the menu item, as shown on the menu. An accelerator key can be specified using the ampersand ‘&’ character. In order to embed an ampersand character in the menu item text, the ampersand must be doubled;
helpString (string) – optional help string that will be shown on the status bar;
kind (integer) – may be
wx.ITEM_SEPARATOR
,wx.ITEM_NORMAL
,wx.ITEM_CHECK
orwx.ITEM_RADIO
;subMenu – if not
None
, the sub menu this item belongs to (an instance ofFlatMenu
);normalBmp – normal bitmap to draw to the side of the text, this bitmap is used when the menu is enabled (an instance of
wx.Bitmap
);disabledBmp – ‘greyed’ bitmap to draw to the side of the text, this bitmap is used when the menu is disabled, if none supplied normal is used (an instance of
wx.Bitmap
);hotBmp – hot bitmap to draw to the side of the text, this bitmap is used when the menu is hovered, if non supplied, normal is used (an instance of
wx.Bitmap
).
- Check(self, check=True)¶
Checks or unchecks the menu item.
- Parameters:
check (bool) –
True
to check the menu item,False
to uncheck it.
Note
This method is meaningful only for menu items of
wx.ITEM_CHECK
orwx.ITEM_RADIO
kind.
- Enable(self, enable=True)¶
Enables or disables a menu item.
- Parameters:
enable (bool) –
True
to enable the menu item,False
to disable it.
- GetAcceleratorEntry(self)¶
Returns the accelerator entry associated to this menu item.
- GetAccelString(self)¶
Returns the accelerator string.
- GetBitmap(self)¶
Returns the normal bitmap associated to the menu item or
NullBitmap
if none has been supplied.
- GetContextMenu(self)¶
Returns the context menu associated with this item (if any).
- GetDisabledBitmap(self)¶
Returns the disabled bitmap associated to the menu item or
NullBitmap
if none has been supplied.
- GetFont(self)¶
Returns this
FlatMenuItem
font.
- GetHeight(self)¶
Returns the menu item height, in pixels.
- GetHelp(self)¶
Returns the item help string.
- GetHotBitmap(self)¶
Returns the hot bitmap associated to the menu item or
NullBitmap
if none has been supplied.
- GetId(self)¶
Returns the item id.
- GetKind(self)¶
Returns the menu item kind, can be one of
wx.ITEM_SEPARATOR
,wx.ITEM_NORMAL
,wx.ITEM_CHECK
orwx.ITEM_RADIO
.
- GetLabel(self)¶
Returns the menu item label (without the accelerator if it is part of the string).
- GetLongHelp(self)¶
Returns the item long help string (displayed in the parent frame
StatusBar
).
- GetMenu(self)¶
Returns the parent menu.
- GetMnemonicChar(self)¶
Returns the shortcut char for this menu item.
- GetRect(self)¶
Returns the menu item client rectangle.
- GetShortHelp(self)¶
Returns the item short help string (displayed in the tool’s tooltip).
- GetSubMenu(self)¶
Returns the sub-menu of this menu item (if any).
- GetSuitableBitmap(self, selected)¶
Gets the bitmap that should be used based on the item state.
- Parameters:
selected (bool) –
True
if this menu item is currently hovered by the mouse,False
otherwise.
- GetText(self)¶
Returns the text associated with the menu item including the accelerator.
- GetTextColour(self)¶
Returns this
FlatMenuItem
foreground text colour.
- IsCheckable(self)¶
Returns
True
if this item is of typewx.ITEM_CHECK
,False
otherwise.
- IsChecked(self)¶
Returns whether an item is checked or not.
Note
This method is meaningful only for items of kind
wx.ITEM_CHECK
orwx.ITEM_RADIO
.
- IsEnabled(self)¶
Returns whether an item is enabled or not.
- IsRadioItem(self)¶
Returns
True
if this item is of typewx.ITEM_RADIO
,False
otherwise.
- IsSeparator(self)¶
Returns
True
if this item is of typewx.ITEM_SEPARATOR
,False
otherwise.
- IsShown(self)¶
Returns whether an item is shown or not.
- IsSubMenu(self)¶
Returns whether an item is a sub-menu or not.
- SetContextMenu(self, context_menu)¶
Assigns a context menu to this item.
- Parameters:
context_menu – an instance of
FlatMenu
.
- SetDisabledBitmap(self, bmp)¶
Sets the menu item disabled bitmap.
- Parameters:
bmp – an instance of
wx.Bitmap
.
- SetFont(self, font=None)¶
Sets the
FlatMenuItem
font.- Parameters:
font – an instance of a valid
wx.Font
.
- SetHelp(self, helpString)¶
Sets the menu item help string.
- Parameters:
helpString (string) – the new menu item help string.
- SetLabel(self, text)¶
Sets the label text for this item from the text (excluding the accelerator).
- Parameters:
text (string) – the new item label (excluding the accelerator).
- SetLongHelp(self, help)¶
Sets the item long help string (displayed in the parent frame
StatusBar
).- Parameters:
help (string) – the new item long help string.
- SetMenuBar(self)¶
Links the current menu item with the main
FlatMenuBar
.
- SetNormalBitmap(self, bmp)¶
Sets the menu item normal bitmap.
- Parameters:
bmp – an instance of
wx.Bitmap
.
- SetRect(self, rect)¶
Sets the menu item client rectangle.
- Parameters:
rect – the menu item client rectangle, an instance of
wx.Rect
.
- SetText(self, text)¶
Sets the text for this menu item (including accelerators).
- Parameters:
text (string) – the new item label (including the accelerator).
- SetTextColour(self, colour=None)¶
Sets the
FlatMenuItem
foreground colour for the menu label.- Parameters:
colour – an instance of a valid
wx.Colour
.
- Show(self, show=True)¶
Actually shows/hides the menu item.
- Parameters:
show (bool) –
True
to show the menu item,False
to hide it.