AGW Logo

agw_title FlatMenuItem

A class that represents an item in a menu.

hierarchy Inheritance Diagram

Inheritance diagram for: FlatMenuItem

Inheritance diagram of FlatMenuItem


method_summary Methods Summary

__init__Default class constructor.
CheckChecks or unchecks the menu item.
EnableEnables or disables a menu item.
GetAccelStringReturns the accelerator string.
GetAcceleratorEntryReturns the accelerator entry associated to this menu item.
GetBitmapReturns the normal bitmap associated to the menu item or wx.NullBitmap if
GetContextMenuReturns the context menu associated with this item (if any).
GetDisabledBitmapReturns the disabled bitmap associated to the menu item or wx.NullBitmap
GetFontReturns this FlatMenuItem font.
GetHeightReturns the menu item height, in pixels.
GetHelpReturns the item help string.
GetHotBitmapReturns the hot bitmap associated to the menu item or wx.NullBitmap if
GetIdReturns the item id.
GetKindReturns the menu item kind, can be one of wx.ITEM_SEPARATOR, wx.ITEM_NORMAL,
GetLabelReturns the menu item label (without the accelerator if it is part of the string).
GetLongHelpReturns the item long help string (displayed in the parent frame wx.StatusBar).
GetMenuReturns the parent menu.
GetMnemonicCharReturns the shortcut char for this menu item.
GetRectReturns the menu item client rectangle.
GetShortHelpReturns the item short help string (displayed in the tool’s tooltip).
GetSubMenuReturns the sub-menu of this menu item (if any).
GetSuitableBitmapGets the bitmap that should be used based on the item state.
GetTextReturns the text associated with the menu item including the accelerator.
GetTextColourReturns this FlatMenuItem foreground text colour.
IsCheckableReturns True if this item is of type wx.ITEM_CHECK, False otherwise.
IsCheckedReturns whether an item is checked or not.
IsEnabledReturns whether an item is enabled or not.
IsRadioItemReturns True if this item is of type wx.ITEM_RADIO, False otherwise.
IsSeparatorReturns True if this item is of type wx.ITEM_SEPARATOR, False otherwise.
IsShownReturns whether an item is shown or not.
IsSubMenuReturns whether an item is a sub-menu or not.
SetContextMenuAssigns a context menu to this item.
SetDisabledBitmapSets the menu item disabled bitmap.
SetFontSets the FlatMenuItem font.
SetHelpSets the menu item help string.
SetHotBitmapSets the menu item hot bitmap.
SetLabelSets the label text for this item from the text (excluding the accelerator).
SetLongHelpSets the item long help string (displayed in the parent frame wx.StatusBar).
SetMenuSets the menu item parent menu.
SetMenuBarLinks the current menu item with the main FlatMenuBar.
SetNormalBitmapSets the menu item normal bitmap.
SetRectSets the menu item client rectangle.
SetSubMenuSets the menu item sub-menu.
SetTextSets the text for this menu item (including accelerators).
SetTextColourSets the FlatMenuItem foreground colour for the menu label.
ShowActually shows/hides the menu item.

API Class API

class FlatMenuItem(object)[source]

A class that represents an item in a menu.



__init__(parent, id=wx.ID_SEPARATOR, label="", helpString="", kind=wx.ITEM_NORMAL, subMenu=None, normalBmp=wx.NullBitmap, disabledBmp=wx.NullBitmap, hotBmp=wx.NullBitmap)[source]

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 or wx.ITEM_RADIO;
  • subMenu – if not None, the sub menu this item belongs to (an instance of FlatMenu);
  • 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(check=True)[source]

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 or wx.ITEM_RADIO kind.



Enable(enable=True)[source]

Enables or disables a menu item.

Parameters:enable (bool) – True to enable the menu item, False to disable it.


GetAccelString()[source]

Returns the accelerator string.



GetAcceleratorEntry()[source]

Returns the accelerator entry associated to this menu item.



GetBitmap()[source]

Returns the normal bitmap associated to the menu item or wx.NullBitmap if none has been supplied.



GetContextMenu()[source]

Returns the context menu associated with this item (if any).



GetDisabledBitmap()[source]

Returns the disabled bitmap associated to the menu item or wx.NullBitmap if none has been supplied.



GetFont()[source]

Returns this FlatMenuItem font.



GetHeight()[source]

Returns the menu item height, in pixels.



GetHelp()[source]

Returns the item help string.



GetHotBitmap()[source]

Returns the hot bitmap associated to the menu item or wx.NullBitmap if none has been supplied.



GetId()[source]

Returns the item id.



GetKind()[source]

Returns the menu item kind, can be one of wx.ITEM_SEPARATOR, wx.ITEM_NORMAL, wx.ITEM_CHECK or wx.ITEM_RADIO.



GetLabel()[source]

Returns the menu item label (without the accelerator if it is part of the string).



GetLongHelp()[source]

Returns the item long help string (displayed in the parent frame wx.StatusBar).



GetMenu()[source]

Returns the parent menu.



GetMnemonicChar()[source]

Returns the shortcut char for this menu item.



GetRect()[source]

Returns the menu item client rectangle.



GetShortHelp()[source]

Returns the item short help string (displayed in the tool’s tooltip).



GetSubMenu()[source]

Returns the sub-menu of this menu item (if any).



GetSuitableBitmap(selected)[source]

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()[source]

Returns the text associated with the menu item including the accelerator.



GetTextColour()[source]

Returns this FlatMenuItem foreground text colour.



IsCheckable()[source]

Returns True if this item is of type wx.ITEM_CHECK, False otherwise.



IsChecked()[source]

Returns whether an item is checked or not.

Note

This method is meaningful only for items of kind wx.ITEM_CHECK or wx.ITEM_RADIO.



IsEnabled()[source]

Returns whether an item is enabled or not.



IsRadioItem()[source]

Returns True if this item is of type wx.ITEM_RADIO, False otherwise.



IsSeparator()[source]

Returns True if this item is of type wx.ITEM_SEPARATOR, False otherwise.



IsShown()[source]

Returns whether an item is shown or not.



IsSubMenu()[source]

Returns whether an item is a sub-menu or not.



SetContextMenu(context_menu)[source]

Assigns a context menu to this item.

Parameters:context_menu – an instance of FlatMenu.


SetDisabledBitmap(bmp)[source]

Sets the menu item disabled bitmap.

Parameters:bmp – an instance of wx.Bitmap.



SetFont(font=None)[source]

Sets the FlatMenuItem font.

Parameters:font – an instance of a valid wx.Font.


SetHelp(helpString)[source]

Sets the menu item help string.

Parameters:helpString (string) – the new menu item help string.


SetHotBitmap(bmp)[source]

Sets the menu item hot bitmap.

Parameters:bmp – an instance of wx.Bitmap.



SetLabel(text)[source]

Sets the label text for this item from the text (excluding the accelerator).

Parameters:text (string) – the new item label (excluding the accelerator).


SetLongHelp(help)[source]

Sets the item long help string (displayed in the parent frame wx.StatusBar).

Parameters:help (string) – the new item long help string.


SetMenu(menu)[source]

Sets the menu item parent menu.

Parameters:menu – an instance of FlatMenu.


SetMenuBar()[source]

Links the current menu item with the main FlatMenuBar.



SetNormalBitmap(bmp)[source]

Sets the menu item normal bitmap.

Parameters:bmp – an instance of wx.Bitmap.



SetRect(rect)[source]

Sets the menu item client rectangle.

Parameters:rect – the menu item client rectangle, an instance of wx.Rect.


SetSubMenu(menu)[source]

Sets the menu item sub-menu.

Parameters:menu – an instance of FlatMenu.


SetText(text)[source]

Sets the text for this menu item (including accelerators).

Parameters:text (string) – the new item label (including the accelerator).


SetTextColour(colour=None)[source]

Sets the FlatMenuItem foreground colour for the menu label.

Parameters:colour – an instance of a valid wx.Colour.


Show(show=True)[source]

Actually shows/hides the menu item.

Parameters:show (bool) – True to show the menu item, False to hide it.
Tree

Table Of Contents

Previous topic

FlatMenuEvent

Next topic

FlatMenuItemGroup