Phoenix Logo

phoenix_title wx.lib.agw.flatmenu.FlatMenuItem

A class that represents an item in a menu.


class_hierarchy Class Hierarchy

Inheritance diagram for class FlatMenuItem:


method_summary Methods Summary

__init__ Default class constructor.
Check Checks or unchecks the menu item.
Enable Enables or disables a menu item.
GetAcceleratorEntry Returns the accelerator entry associated to this menu item.
GetAccelString Returns the accelerator string.
GetBitmap Returns the normal bitmap associated to the menu item or NullBitmap if
GetContextMenu Returns the context menu associated with this item (if any).
GetDisabledBitmap Returns the disabled bitmap associated to the menu item or NullBitmap
GetFont Returns this FlatMenuItem font.
GetHeight Returns the menu item height, in pixels.
GetHelp Returns the item help string.
GetHotBitmap Returns the hot bitmap associated to the menu item or NullBitmap if
GetId Returns the item id.
GetKind Returns the menu item kind, can be one of wx.ITEM_SEPARATOR, wx.ITEM_NORMAL,
GetLabel Returns the menu item label (without the accelerator if it is part of the string).
GetLongHelp Returns the item long help string (displayed in the parent frame StatusBar).
GetMenu Returns the parent menu.
GetMnemonicChar Returns the shortcut char for this menu item.
GetRect Returns the menu item client rectangle.
GetShortHelp Returns the item short help string (displayed in the tool’s tooltip).
GetSubMenu Returns the sub-menu of this menu item (if any).
GetSuitableBitmap Gets the bitmap that should be used based on the item state.
GetText Returns the text associated with the menu item including the accelerator.
GetTextColour Returns this FlatMenuItem foreground text colour.
IsCheckable Returns True if this item is of type wx.ITEM_CHECK, False otherwise.
IsChecked Returns whether an item is checked or not.
IsEnabled Returns whether an item is enabled or not.
IsRadioItem Returns True if this item is of type wx.ITEM_RADIO, False otherwise.
IsSeparator Returns True if this item is of type wx.ITEM_SEPARATOR, False otherwise.
IsShown Returns whether an item is shown or not.
IsSubMenu Returns whether an item is a sub-menu or not.
SetContextMenu Assigns a context menu to this item.
SetDisabledBitmap Sets the menu item disabled bitmap.
SetFont Sets the FlatMenuItem font.
SetHelp Sets the menu item help string.
SetHotBitmap Sets the menu item hot bitmap.
SetLabel Sets the label text for this item from the text (excluding the accelerator).
SetLongHelp Sets the item long help string (displayed in the parent frame StatusBar).
SetMenu Sets the menu item parent menu.
SetMenuBar Links the current menu item with the main FlatMenuBar.
SetNormalBitmap Sets the menu item normal bitmap.
SetRect Sets the menu item client rectangle.
SetSubMenu Sets the menu item sub-menu.
SetText Sets the text for this menu item (including accelerators).
SetTextColour Sets the FlatMenuItem foreground colour for the menu label.
Show Actually shows/hides the menu item.

api 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 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(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 or wx.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 or wx.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 type wx.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 or wx.ITEM_RADIO.



IsEnabled(self)

Returns whether an item is enabled or not.



IsRadioItem(self)

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



IsSeparator(self)

Returns True if this item is of type wx.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.


SetHotBitmap(self, bmp)

Sets the menu item hot bitmap.

Parameters:bmp – an instance of wx.Bitmap.


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.


SetMenu(self, menu)

Sets the menu item parent menu.

Parameters:menu – an instance of FlatMenu.


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.


SetSubMenu(self, menu)

Sets the menu item sub-menu.

Parameters:menu – an instance of FlatMenu.


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.