wx.lib.agw.flatmenu.FlatMenuBar¶
Implements the generic owner-drawn menu bar for FlatMenu
.
Class Hierarchy¶
Control Appearance¶
Known Superclasses¶
Methods Summary¶
Default class constructor. |
|
Activates a menu. |
|
Activates next menu and make sure all others are non-active. |
|
Activates previous menu and make sure all others are non-active. |
|
Adds a new check (or toggle) tool to the toolbar. |
|
Adds any control to the toolbar, typically e.g. a combobox. |
|
Adds a new radio tool to the toolbar. |
|
Adds a separator for spacing groups of tools in toolbar. |
|
Adds a tool to the toolbar. |
|
Adds the item to the end of the menu bar. |
|
Appends a tool to the |
|
Restores a |
|
Creates the drop down menu and populate it. |
|
Gives tooltips and help in |
|
Handles mouse move event. |
|
Performs a toolbar button pressed action. |
|
Draws ‘more’ button to the right side of the menu bar. |
|
Draws the toolbar (if present). |
|
Draws a toolbar item button. |
|
Returns the index of the menu with the given title or |
|
Finds the menu item object associated with the given menu item identifier. |
|
Returns the active toolbar item. |
|
Returns the menu bar background colour. |
|
Returns the number of invisible menu items. |
|
Returns the number of invisible toolbar items. |
|
Returns the index of the last visible menu on the menu bar. |
|
Returns the menu at the specified index menuIdx (zero-based). |
|
Returns the number of menus in the menubar. |
|
Returns a rectangle region, as an instance of |
|
Returns the |
|
Returns the renderer associated with this instance. |
|
Returns the |
|
HitTest method for |
|
Inserts the menu at the given position into the menu bar. |
|
Single function to handle any accelerator key used inside the menubar. |
|
Handles the customize dialog here. |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the |
|
Handles the timer expiring to delete the longHelp string in the |
|
Pops up the ‘more’ menu. |
|
Positions the control inside a wxAUI / PyAUI frame manager. |
|
This function is called from child menus, this allow a child menu to |
|
Removes the menu from the menu bar and returns the menu object - the |
|
Removes the tooltips and statusbar help (if any) for a button. |
|
Used internally. |
|
Sets the menu bar background colour. |
|
Recalculates the |
|
Sets whether the PC monitor is an LCD or not. |
|
Sets the margin above and below the menu bar text. |
|
Sets the |
|
Sets the spacing between the menubar items. |
|
Sets the margin around the toolbar. |
|
Sets the spacing between the toolbar tools. |
|
Sets the UpdateUI interval for toolbar items. All UpdateUI events are |
|
Shows/hides the drop-down arrow which allows customization of |
|
Updates the parent accelerator table. |
|
An item was modified. This function is called by |
Class API¶
- class FlatMenuBar(wx.Panel)¶
Implements the generic owner-drawn menu bar for
FlatMenu
.
Methods¶
- __init__(self, parent, id=wx.ID_ANY, iconSize=SmallIcons, spacer=SPACER, options=FM_OPT_SHOW_CUSTOMIZE | FM_OPT_IS_LCD)¶
Default class constructor.
- Parameters:
parent – the menu bar parent, must not be
None
;id (integer) – the window identifier. If
wx.ID_ANY
, will automatically create an identifier;iconSize (integer) –
size of the icons in the toolbar. This can be one of the following values (in pixels):
iconSize Bit
Value
Description
LargeIcons
32
Use large 32x32 icons
SmallIcons
16
Use standard 16x16 icons
spacer (integer) – the space between the menu bar text and the menu bar border;
options (integer) – a combination of the following bits:
options Bit
Hex Value
Description
FM_OPT_IS_LCD
0x1
Use this style if your computer uses a LCD screen
FM_OPT_MINIBAR
0x2
Use this if you plan to use toolbar only
FM_OPT_SHOW_CUSTOMIZE
0x4
Show “customize link” in more menus, you will need to write your own handler. See demo.
FM_OPT_SHOW_TOOLBAR
0x8
Set this option is you are planing to use the toolbar
- ActivateMenu(self, menuInfo)¶
Activates a menu.
- Parameters:
menuInfo – an instance of
wx.MenuEntryInfo
.
- ActivateNextMenu(self)¶
Activates next menu and make sure all others are non-active.
- ActivatePreviousMenu(self)¶
Activates previous menu and make sure all others are non-active.
- AddCheckTool(self, toolId, label='', bitmap1=wx.NullBitmap, bitmap2=wx.NullBitmap, shortHelp='', longHelp='')¶
Adds a new check (or toggle) tool to the toolbar.
See also
AddTool
for parameter descriptions.
- AddControl(self, control)¶
Adds any control to the toolbar, typically e.g. a combobox.
- Parameters:
control – the control to be added, a subclass of
wx.Window
(but noTopLevelWindow
).
- AddRadioTool(self, toolId, label='', bitmap1=wx.NullBitmap, bitmap2=wx.NullBitmap, shortHelp='', longHelp='')¶
Adds a new radio tool to the toolbar.
Consecutive radio tools form a radio group such that exactly one button in the group is pressed at any moment, in other words whenever a button in the group is pressed the previously pressed button is automatically released.
You should avoid having the radio groups of only one element as it would be impossible for the user to use such button.
By default, the first button in the radio group is initially pressed, the others are not.
See also
AddTool
for parameter descriptions.
- AddSeparator(self)¶
Adds a separator for spacing groups of tools in toolbar.
- AddTool(self, toolId, label='', bitmap1=wx.NullBitmap, bitmap2=wx.NullBitmap, kind=wx.ITEM_NORMAL, shortHelp='', longHelp='')¶
Adds a tool to the toolbar.
- Parameters:
toolId (integer) – an integer by which the tool may be identified in subsequent operations;
label (string) – the tool label string;
kind (integer) – may be
wx.ITEM_NORMAL
for a normal button (default),wx.ITEM_CHECK
for a checkable tool (such tool stays pressed after it had been toggled) orwx.ITEM_RADIO
for a checkable tool which makes part of a radio group of tools each of which is automatically unchecked whenever another button in the group is checked;bitmap1 – the primary tool bitmap, an instance of
wx.Bitmap
;bitmap2 – the bitmap used when the tool is disabled. If it is equal to
NullBitmap
, the disabled bitmap is automatically generated by greing out the normal one;shortHelp (string) – a string used for the tools tooltip;
longHelp (string) – this string is shown in the
StatusBar
(if any) of the parent frame when the mouse pointer is inside the tool.
- Append(self, menu, title)¶
Adds the item to the end of the menu bar.
- Parameters:
menu – the menu to which we are appending a new item, an instance of
FlatMenu
;title (string) – the menu item label, must not be empty.
See also
- AppendToolbarItem(self, item)¶
Appends a tool to the
FlatMenuBar
.Deprecated since version 0.9.5: This method is now deprecated.
See also
- ClearBitmaps(self, start=0)¶
Restores a
NullBitmap
for all the items in the menu.- Parameters:
start (integer) – the index at which to start resetting the bitmaps.
- CreateMoreMenu(self)¶
Creates the drop down menu and populate it.
- DoGiveHelp(self, hit)¶
Gives tooltips and help in
StatusBar
.- Parameters:
hit – the toolbar tool currently hovered by the mouse.
- DoMouseMove(self, pt, leftIsDown)¶
Handles mouse move event.
- Parameters:
pt – an instance of
wx.Point
;leftIsDown (bool) –
True
is the left mouse button is down,False
otherwise.
- DoToolbarAction(self, idx)¶
Performs a toolbar button pressed action.
- Parameters:
idx (integer) – the tool index in the toolbar.
- DrawMoreButton(self, dc, state)¶
Draws ‘more’ button to the right side of the menu bar.
- Parameters:
dc – an instance of
wx.DC
;state (integer) – the ‘more’ button state.
See also
wx.MenuEntryInfo.SetState()
for a list of valid menu states.
- DrawToolbar(self, dc, rect)¶
Draws the toolbar (if present).
- DrawToolbarItem(self, dc, idx, state)¶
Draws a toolbar item button.
- Parameters:
dc – an instance of
wx.DC
;idx (integer) – the tool index in the toolbar;
state (integer) – the button state.
See also
wx.MenuEntryInfo.SetState()
for a list of valid menu states.
- FindMenu(self, title)¶
Returns the index of the menu with the given title or
wx.NOT_FOUND
if no such menu exists in this menubar.- Parameters:
title (string) – may specify either the menu title (with accelerator characters, i.e. “&File”) or just the menu label (“File”) indifferently.
- FindMenuItem(self, id)¶
Finds the menu item object associated with the given menu item identifier.
- Parameters:
id (integer) – the identifier for the sought
FlatMenuItem
.- Returns:
The found menu item object, or
None
if one was not found.
- GetActiveToolbarItem(self)¶
Returns the active toolbar item.
- GetBackgroundColour(self)¶
Returns the menu bar background colour.
- GetInvisibleMenuItemCount(self)¶
Returns the number of invisible menu items.
Note
Valid only after the
PaintEvent
has been processed after a resize.
- GetInvisibleToolbarItemCount(self)¶
Returns the number of invisible toolbar items.
Note
Valid only after the
PaintEvent
has been processed after a resize.
- GetLastVisibleMenu(self)¶
Returns the index of the last visible menu on the menu bar.
- GetMenu(self, menuIdx)¶
Returns the menu at the specified index menuIdx (zero-based).
- Parameters:
menuIdx (integer) – the index of the sought menu.
- Returns:
The found menu item object, or
None
if one was not found.
- GetMenuCount(self)¶
Returns the number of menus in the menubar.
- GetMoreMenuButtonRect(self)¶
Returns a rectangle region, as an instance of
wx.Rect
, surrounding the menu button.
- GetOptions(self)¶
Returns the
FlatMenuBar
options, whether to show a toolbar, to use LCD screen settings etc…See also
SetOptions
for a list of valid options.
- GetRenderer(self)¶
Returns the renderer associated with this instance.
- GetRendererManager(self)¶
Returns the
FlatMenuBar
renderer manager.
- HitTest(self, pt)¶
HitTest method for
FlatMenuBar
.- Parameters:
pt – an instance of
wx.Point
, specifying the hit test position.- Returns:
A tuple representing one of the following combinations:
Return Tuple
Description
(-1, 0)
The
HitTest
method didn’t find any item with the specified input point pt (NoWhere
= 0)(integer, 1)
A menu item has been hit, its position specified by the tuple item integer (
MenuItem
= 1)(integer, 2)
A toolbar item has ben hit, its position specified by the tuple item integer (
ToolbarItem
= 2)(-1, 3)
The drop-down area button has been hit (
DropDownArrowButton
= 3)
- Insert(self, pos, menu, title)¶
Inserts the menu at the given position into the menu bar.
- Parameters:
pos (integer) – the position of the new menu in the menu bar;
menu – the menu to add, an instance of
FlatMenu
.FlatMenuBar
owns the menu and will free it;title (string) – the title of the menu.
Note
Inserting menu at position 0 will insert it in the very beginning of it, inserting at position
GetMenuCount
is the same as callingAppend
.
- OnAccelCmd(self, event)¶
Single function to handle any accelerator key used inside the menubar.
- Parameters:
event – a
FlatMenuEvent
event to be processed.
- OnCustomizeDlg(self, event)¶
Handles the customize dialog here.
- Parameters:
event – a
FlatMenuEvent
event to be processed.
- OnEraseBackground(self, event)¶
Handles the
wx.EVT_ERASE_BACKGROUND
event forFlatMenuBar
.- Parameters:
event – a
EraseEvent
event to be processed.
Note
This method is intentionally empty to reduce flicker.
- OnIdle(self, event)¶
Handles the
wx.EVT_IDLE
event forFlatMenuBar
.- Parameters:
event – a
IdleEvent
event to be processed.
- OnLeaveMenuBar(self, event)¶
Handles the
wx.EVT_LEAVE_WINDOW
event forFlatMenuBar
.- Parameters:
event – a
MouseEvent
event to be processed.
Note
This method is for MSW only.
- OnLeaveWindow(self, event)¶
Handles the
wx.EVT_LEAVE_WINDOW
event forFlatMenuBar
.- Parameters:
event – a
MouseEvent
event to be processed.
Note
This method is for GTK only.
- OnLeftDown(self, event)¶
Handles the
wx.EVT_LEFT_DOWN
event forFlatMenuBar
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnLeftUp(self, event)¶
Handles the
wx.EVT_LEFT_UP
event forFlatMenuBar
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnMenuDismissed(self, event)¶
Handles the
EVT_FLAT_MENU_DISMISSED
event forFlatMenuBar
.- Parameters:
event – a
FlatMenuEvent
event to be processed.
- OnMouseMove(self, event)¶
Handles the
wx.EVT_MOTION
event forFlatMenuBar
.- Parameters:
event – a
MouseEvent
event to be processed.
- OnPaint(self, event)¶
Handles the
wx.EVT_PAINT
event forFlatMenuBar
.- Parameters:
event – a
PaintEvent
event to be processed.
- OnSize(self, event)¶
Handles the
wx.EVT_SIZE
event forFlatMenuBar
.- Parameters:
event – a
wx.SizeEvent
event to be processed.
- OnStatusBarTimer(self)¶
Handles the timer expiring to delete the longHelp string in the
StatusBar
.
- PopupMoreMenu(self)¶
Pops up the ‘more’ menu.
- PositionAUI(self, mgr, fixToolbar=True)¶
Positions the control inside a wxAUI / PyAUI frame manager.
- Parameters:
mgr – an instance of
AuiManager
orframemanager
;fixToolbar (bool) –
True
ifFlatMenuBar
can not be floated.
- ProcessMouseMoveFromMenu(self, pt)¶
This function is called from child menus, this allow a child menu to pass the mouse movement event to the menu bar.
- Parameters:
pt – an instance of
wx.Point
.
- Remove(self, pos)¶
Removes the menu from the menu bar and returns the menu object - the caller is responsible for deleting it.
- Parameters:
pos (integer) – the position of the menu in the menu bar.
Note
This function may be used together with
Insert
to change the menubar dynamically.
- RemoveHelp(self)¶
Removes the tooltips and statusbar help (if any) for a button.
- ResetToolbarItems(self)¶
Used internally.
- SetBackgroundColour(self, colour)¶
Sets the menu bar background colour.
- Parameters:
colour – a valid
wx.Colour
.
- SetBarHeight(self)¶
Recalculates the
FlatMenuBar
height when its settings change.
- SetLCDMonitor(self, lcd=True)¶
Sets whether the PC monitor is an LCD or not.
- Parameters:
lcd (bool) –
True
to use the settings appropriate for a LCD monitor,False
otherwise.
- SetMargin(self, margin)¶
Sets the margin above and below the menu bar text.
- Parameters:
margin (integer) – height in pixels of the margin.
- SetOptions(self, options)¶
Sets the
FlatMenuBar
options, whether to show a toolbar, to use LCD screen settings etc…- Parameters:
options (integer) – a combination of the following bits:
options Bit
Hex Value
Description
FM_OPT_IS_LCD
0x1
Use this style if your computer uses a LCD screen
FM_OPT_MINIBAR
0x2
Use this if you plan to use toolbar only
FM_OPT_SHOW_CUSTOMIZE
0x4
Show “customize link” in more menus, you will need to write your own handler. See demo.
FM_OPT_SHOW_TOOLBAR
0x8
Set this option is you are planing to use the toolbar
- SetSpacing(self, spacer)¶
Sets the spacing between the menubar items.
- Parameters:
spacer (integer) – number of pixels between each menu item.
- SetToolbarMargin(self, margin)¶
Sets the margin around the toolbar.
- Parameters:
margin (integer) – width in pixels of the margin around the tools in the toolbar.
- SetToolbarSpacing(self, spacer)¶
Sets the spacing between the toolbar tools.
- Parameters:
spacer (integer) – number of pixels between each tool in the toolbar.
- SetUpdateInterval(self, interval)¶
Sets the UpdateUI interval for toolbar items. All UpdateUI events are sent from within
OnIdle
handler, the default is 20 milliseconds.- Parameters:
interval (integer) – the updateUI interval in milliseconds.
- ShowCustomize(self, show=True)¶
Shows/hides the drop-down arrow which allows customization of
FlatMenu
.- Parameters:
show (bool) –
True
to show the customize menu,False
to hide it.
- UpdateAcceleratorTable(self)¶
Updates the parent accelerator table.