A Flat popup menu generic implementation.
__init__ |
Default class constructor. |
AddItem |
Internal function to add the item to this menu. The item must |
AdvanceSelection |
Advance forward or backward the current selection. |
Append |
Appends an item to this menu. |
AppendCheckItem |
Adds a checkable item to the end of the menu. |
AppendItem |
Appends an item to this menu. |
AppendMenu |
Adds a pull-right submenu to the end of the menu. |
AppendRadioItem |
Adds a radio item to the end of the menu. |
AppendSeparator |
Appends a separator item to the end of this menu. |
AppendSubMenu |
Adds a pull-right submenu to the end of the menu. |
Clear |
Clears the menu items. |
CloseSubMenu |
Closes a child sub-menu. |
DestroyItem |
Deletes the menu item from the menu. If the item is a submenu, it will be |
Dismiss |
Dismisses the popup window. |
DoAction |
Performs an action based on user selection. |
DrawSelection |
Redraws the menu. |
FindItem |
Finds the menu item object associated with the given menu item identifier and, |
FindMenuItemPos |
Finds an item and its position inside the menu based on its id. |
FindMenuItemPosSimple |
Finds an item and its position inside the menu based on its id. |
GetAccelArray |
Returns a list filled with the accelerator entries for the menu. |
GetAccelTable |
Returns the menu accelerator table, an instance of AcceleratorTable . |
GetAllItems |
Internal function to help recurse through all the menu items. |
GetBackgroundBitmap |
Returns the background bitmap for this particular FlatMenu , if any. |
GetBorderXWidth |
Returns the menu border x-width, in pixels. |
GetBorderYWidth |
Returns the menu border y-width, in pixels. |
GetItemFont |
Returns this FlatMenuItem font. |
GetItemHeight |
Returns the height of a particular item, in pixels. |
GetItemTextColour |
Returns this FlatMenuItem foreground text colour. |
GetLabel |
Returns the label of a FlatMenuItem . |
GetLeftMarginWidth |
Returns the menu left margin width, in pixels. |
GetMenuBar |
Returns the menubar associated with this menu item. |
GetMenuBarForSubMenu |
Returns the menubar associated with this menu item. |
GetMenuItemCount |
Returns the number of items in the FlatMenu . |
GetMenuItems |
Returns the list of menu items in the menu. |
GetMenuItemWidth |
Returns the width of a particular item. |
GetMenuRect |
Returns the menu client rectangle. |
GetMenuWidth |
Returns the menu width in pixels. |
GetNumberColumns |
Returns the number of columns for a menu window. |
GetRightMarginWidth |
Returns the menu right margin width, in pixels. |
GetSiblingGroupItem |
Used internally. |
HitTest |
HitTest method for FlatMenu . |
Insert |
Inserts the given item before the position pos. |
InsertItem |
Inserts an item into the menu. |
InsertSeparator |
Inserts a separator at the given position. |
OnChar |
Handles key events for FlatMenu . |
OnEraseBackground |
Handles the wx.EVT_ERASE_BACKGROUND event for FlatMenu . |
OnKeyDown |
Handles the wx.EVT_KEY_DOWN event for FlatMenu . |
OnKillFocus |
Handles the wx.EVT_KILL_FOCUS event for FlatMenu . |
OnMouseEnterWindow |
Handles the wx.EVT_ENTER_WINDOW event for FlatMenu . |
OnMouseLeaveWindow |
Handles the wx.EVT_LEAVE_WINDOW event for FlatMenu . |
OnMouseLeftDown |
Handles the wx.EVT_LEFT_DOWN event for FlatMenu . |
OnMouseLeftUp |
Handles the wx.EVT_LEFT_UP event for FlatMenu . |
OnMouseMove |
Handles the wx.EVT_MOTION event for FlatMenu . |
OnMouseRightDown |
Handles the wx.EVT_RIGHT_DOWN event for FlatMenu . |
OnPaint |
Handles the wx.EVT_PAINT event for FlatMenu . |
OnTimer |
Handles the wx.EVT_TIMER event for FlatMenu . |
OpenItemContextMenu |
Open an item’s context menu (if any). |
Popup |
Pops up the menu. |
Prepend |
Prepends an item to this menu. |
PrependItem |
Prepends an item to this menu. |
ProcessMouseLClick |
Processes mouse left clicks. |
ProcessMouseLClickEnd |
Processes mouse left clicks. |
ProcessMouseMove |
Processes mouse movements. |
ProcessMouseRClick |
Processes mouse right clicks. |
RefreshChilds |
In some cases, we need to perform a recursive refresh for all opened submenu |
Remove |
Removes the menu item from the menu but doesn’t delete the associated menu |
ResizeMenu |
Resizes the menu to the correct size. |
ScrollDown |
Scrolls the menu down (for very tall menus). |
ScrollUp |
Scrolls the menu up (for very tall menus). |
SendCmdEvent |
Actually sends menu command events. |
SendOverItem |
Sends the EVT_FLAT_MENU_ITEM_MOUSE_OVER and EVT_FLAT_MENU_ITEM_MOUSE_OUT |
SendUIEvent |
Actually sends menu UI events. |
SetBackgroundBitmap |
Sets a background bitmap for this particular FlatMenu . |
SetItemFont |
Sets the FlatMenuItem font. |
SetItemTextColour |
Sets the FlatMenuItem foreground text colour. |
SetLabel |
Sets the label of a FlatMenuItem . |
SetMenuBar |
Attaches this menu to a menubar. |
SetNumberColumns |
Sets the number of columns for a menu window. |
SetSubMenuBar |
Attaches this menu to a menubar. |
TryOpenSubMenu |
If itemIdx is an item with submenu, open it. |
TryScrollButtons |
Used internally. |
UpdateItem |
Updates an item. |
UpdateRadioGroup |
Updates a group of radio items. |
FlatMenu
(FlatMenuBase)¶A Flat popup menu generic implementation.
__init__
(self, parent=None)¶Default class constructor.
Parameters: | parent – the FlatMenu parent window (used to initialize the
underlying ShadowPopupWindow ). |
---|
AddItem
(self, menuItem)¶Internal function to add the item to this menu. The item must already be in the self._itemsArr attribute.
Parameters: | menuItem – an instance of FlatMenuItem . |
---|
AdvanceSelection
(self, down=True)¶Advance forward or backward the current selection.
Parameters: | down (bool) – True to advance the selection forward, False otherwise. |
---|
Append
(self, id, item, helpString="", kind=wx.ITEM_NORMAL)¶Appends an item to this menu.
Parameters: |
|
---|
AppendCheckItem
(self, id, item, helpString="")¶Adds a checkable item to the end of the menu.
See also
Append
for the explanation of the input parameters.
AppendItem
(self, menuItem)¶Appends an item to this menu.
Parameters: | menuItem – an instance of FlatMenuItem . |
---|
AppendMenu
(self, id, item, subMenu, helpString="")¶Adds a pull-right submenu to the end of the menu.
Parameters: |
|
---|
AppendRadioItem
(self, id, item, helpString="")¶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.
See also
Append
for the explanation of the input parameters.
AppendSeparator
(self)¶Appends a separator item to the end of this menu.
AppendSubMenu
(self, subMenu, item, helpString="")¶Adds a pull-right submenu to the end of the menu.
This function is added to duplicate the API of wx.Menu
.
See also
AppendMenu
for an explanation of the input parameters.
Clear
(self)¶Clears the menu items.
CloseSubMenu
(self, itemIdx, alwaysClose=False)¶Closes a child sub-menu.
Parameters: |
|
---|
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).
Parameters: | item – can be either a menu item identifier or a plain FlatMenuItem . |
---|
Dismiss
(self, dismissParent, resetOwner)¶Dismisses the popup window.
Parameters: |
|
---|
DoAction
(self, itemIdx)¶Performs an action based on user selection.
Parameters: | itemIdx (integer) – the index of the item for which we want to perform the action. |
---|
DrawSelection
(self, dc, oldSelection=-1)¶Redraws the menu.
Parameters: |
|
---|
FindItem
(self, itemId, menu=None)¶Finds the menu item object associated with the given menu item identifier and, optionally, the (sub)menu it belongs to.
Parameters: |
|
---|---|
Returns: | The found menu item object, or |
FindMenuItemPos
(self, itemId, menu=None)¶Finds an item and its position inside the menu based on its id.
Parameters: |
|
---|---|
Returns: | The found menu item object, or |
FindMenuItemPosSimple
(self, item)¶Finds an item and its position inside the menu based on its id.
Parameters: | item – an instance of FlatMenuItem . |
---|---|
Returns: | An integer specifying the index found menu item object, or
wx.NOT_FOUND if one was not found. |
GetAccelArray
(self)¶Returns a list filled with the accelerator entries for the menu.
GetAccelTable
(self)¶Returns the menu accelerator table, an instance of AcceleratorTable
.
GetAllItems
(self, menu=None, items=[])¶Internal function to help recurse through all the menu items.
Parameters: |
|
---|---|
Returns: | a list of |
GetBorderXWidth
(self)¶Returns the menu border x-width, in pixels.
GetBorderYWidth
(self)¶Returns the menu border y-width, in pixels.
GetItemFont
(self, itemId)¶Returns this FlatMenuItem
font.
Parameters: | itemId (integer) – the menu item identifier. |
---|
GetItemHeight
(self)¶Returns the height of a particular item, in pixels.
GetItemTextColour
(self, itemId)¶Returns this FlatMenuItem
foreground text colour.
Parameters: | itemId (integer) – the menu item identifier. |
---|
GetLabel
(self, itemId)¶Returns the label of a FlatMenuItem
.
Parameters: | id (integer) – the menu item identifier; |
---|
See also
GetLeftMarginWidth
(self)¶Returns the menu left margin width, in pixels.
GetMenuBar
(self)¶Returns the menubar associated with this menu item.
GetMenuBarForSubMenu
(self)¶Returns the menubar associated with this menu item.
GetMenuItems
(self)¶Returns the list of menu items in the menu.
GetMenuItemWidth
(self, menuItem)¶Returns the width of a particular item.
Parameters: | menuItem – an instance of FlatMenuItem . |
---|
GetMenuRect
(self)¶Returns the menu client rectangle.
GetMenuWidth
(self)¶Returns the menu width in pixels.
GetNumberColumns
(self)¶Returns the number of columns for a menu window.
GetRightMarginWidth
(self)¶Returns the menu right margin width, in pixels.
GetSiblingGroupItem
(self, item)¶Used internally.
Parameters: | item – an instance of FlatMenuItem . |
---|
HitTest
(self, pos)¶HitTest method for FlatMenu
.
Parameters: | pos – an instance of wx.Point , a point to test for hits. |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple representing one of the following combinations:
|
Insert
(self, pos, id, item, helpString="", kind=wx.ITEM_NORMAL)¶Inserts the given item before the position pos.
Parameters: |
|
---|
InsertItem
(self, pos, item)¶Inserts an item into the menu.
Parameters: |
|
---|
InsertSeparator
(self, pos)¶Inserts a separator at the given position.
Parameters: | pos (integer) – the index at which we want to insert the separator. |
---|
OnEraseBackground
(self, event)¶Handles the wx.EVT_ERASE_BACKGROUND
event for FlatMenu
.
Parameters: | event – a EraseEvent event to be processed. |
---|
Note
This method is intentionally empty to avoid flicker.
OnKeyDown
(self, event)¶Handles the wx.EVT_KEY_DOWN
event for FlatMenu
.
Parameters: | event – a KeyEvent event to be processed. |
---|
OnKillFocus
(self, event)¶Handles the wx.EVT_KILL_FOCUS
event for FlatMenu
.
Parameters: | event – a FocusEvent event to be processed. |
---|
OnMouseEnterWindow
(self, event)¶Handles the wx.EVT_ENTER_WINDOW
event for FlatMenu
.
Parameters: | event – a MouseEvent event to be processed. |
---|
OnMouseLeaveWindow
(self, event)¶Handles the wx.EVT_LEAVE_WINDOW
event for FlatMenu
.
Parameters: | event – a MouseEvent event to be processed. |
---|
OnMouseLeftDown
(self, event)¶Handles the wx.EVT_LEFT_DOWN
event for FlatMenu
.
Parameters: | event – a MouseEvent event to be processed. |
---|
OnMouseLeftUp
(self, event)¶Handles the wx.EVT_LEFT_UP
event for FlatMenu
.
Parameters: | event – a MouseEvent event to be processed. |
---|
OnMouseMove
(self, event)¶Handles the wx.EVT_MOTION
event for FlatMenu
.
Parameters: | event – a MouseEvent event to be processed. |
---|
OnMouseRightDown
(self, event)¶Handles the wx.EVT_RIGHT_DOWN
event for FlatMenu
.
Parameters: | event – a MouseEvent event to be processed. |
---|
OnPaint
(self, event)¶Handles the wx.EVT_PAINT
event for FlatMenu
.
Parameters: | event – a PaintEvent event to be processed. |
---|
OnTimer
(self, event)¶Handles the wx.EVT_TIMER
event for FlatMenu
.
Parameters: | event – a TimerEvent event to be processed. |
---|
OpenItemContextMenu
(self, itemIdx)¶Open an item’s context menu (if any).
Parameters: | itemIdx (integer) – the index of the item for which we want to open the context menu. |
---|
Popup
(self, pt, owner=None, parent=None)¶Pops up the menu.
Parameters: |
|
---|
Prepend
(self, id, item, helpString="", kind=wx.ITEM_NORMAL)¶Prepends an item to this menu.
Parameters: |
|
---|
PrependItem
(self, menuItem)¶Prepends an item to this menu.
Parameters: | menuItem – an instance of FlatMenuItem . |
---|
ProcessMouseLClick
(self, pos)¶Processes mouse left clicks.
Parameters: | pos – the position at which the mouse left button was pressed,
an instance of wx.Point . |
---|
ProcessMouseLClickEnd
(self, pos)¶Processes mouse left clicks.
Parameters: | pos – the position at which the mouse left button was pressed,
an instance of wx.Point . |
---|
ProcessMouseMove
(self, pos)¶Processes mouse movements.
Parameters: | pos – the position at which the mouse was moved, an instance of wx.Point . |
---|
ProcessMouseRClick
(self, pos)¶Processes mouse right clicks.
Parameters: | pos – the position at which the mouse right button was pressed,
an instance of wx.Point . |
---|
RefreshChilds
(self)¶In some cases, we need to perform a recursive refresh for all opened submenu from this.
Remove
(self, item)¶Removes the menu item from the menu but doesn’t delete the associated menu object. This allows to reuse the same item later by adding it back to the menu (especially useful with submenus).
Parameters: | item – can be either a menu item identifier or a plain FlatMenuItem . |
---|
ResizeMenu
(self)¶Resizes the menu to the correct size.
ScrollDown
(self)¶Scrolls the menu down (for very tall menus).
ScrollUp
(self)¶Scrolls the menu up (for very tall menus).
SendCmdEvent
(self, itemIdx)¶Actually sends menu command events.
Parameters: | itemIdx (integer) – the menu item index for which we want to send a command event. |
---|
SendOverItem
(self, itemIdx, over)¶Sends the EVT_FLAT_MENU_ITEM_MOUSE_OVER
and EVT_FLAT_MENU_ITEM_MOUSE_OUT
events.
Parameters: |
|
---|
SendUIEvent
(self, itemIdx)¶Actually sends menu UI events.
Parameters: | itemIdx (integer) – the menu item index for which we want to send a UI event. |
---|
SetBackgroundBitmap
(self, bitmap=None)¶Sets a background bitmap for this particular FlatMenu
.
Parameters: | bitmap – an instance of wx.Bitmap . Set bitmap to None if you
wish to remove the background bitmap altogether. |
---|
Note
the bitmap is rescaled to fit the menu width and height.
SetItemFont
(self, itemId, font=None)¶Sets the FlatMenuItem
font.
Parameters: |
|
---|
SetItemTextColour
(self, itemId, colour=None)¶Sets the FlatMenuItem
foreground text colour.
Parameters: |
|
---|
SetLabel
(self, itemId, label)¶Sets the label of a FlatMenuItem
.
Parameters: |
|
---|
See also
SetMenuBar
(self, mb)¶Attaches this menu to a menubar.
Parameters: | mb – an instance of FlatMenuBar . |
---|
SetNumberColumns
(self, numCols)¶Sets the number of columns for a menu window.
Parameters: | numCols (integer) – the number of columns for this FlatMenu window. |
---|
SetSubMenuBar
(self, mb)¶Attaches this menu to a menubar.
Parameters: | mb – an instance of FlatMenuBar . |
---|
TryOpenSubMenu
(self, itemIdx, selectFirst=False)¶If itemIdx is an item with submenu, open it.
Parameters: |
|
---|
TryScrollButtons
(self, event)¶Used internally.
UpdateItem
(self, item)¶Updates an item.
Parameters: | item – an instance of FlatMenuItem . |
---|
UpdateRadioGroup
(self, item)¶Updates a group of radio items.
Parameters: | item – an instance of FlatMenuItem . |
---|