Enter search terms or a module, class or function name.
A menu bar is a series of menus accessible from the top of a frame.
If you have a toolbar which uses the same identifiers as your EVT_MENU entries, events from the toolbar will also be processed by your EVT_MENU event handlers.
Tip: under Windows, if you discover that menu shortcuts (for example, Alt-F to show the file menu) are not working, check any EVT_CHAR events you are handling in child windows. If you are not calling event.Skip() for events that you don’t process in these event handlers, menu shortcuts may cease to work.
Note
To respond to a menu selection, provide a handler for EVT_MENU, in the frame that contains the menu bar.
See also
__init__ | Construct an empty menu bar. |
Append | Adds the item to the end of the menu bar. |
Attach | |
Check | Checks or unchecks a menu item. |
Detach | |
Enable | Enables or disables (greys out) a menu item. |
EnableTop | Enables or disables a whole menu. |
FindMenu | Returns the index of the menu with the given title or NOT_FOUND if no such menu exists in this menubar. |
FindMenuItem | Finds the menu item id for a menu name/menu item string pair. |
GetFrame | |
GetHelpString | Gets the help string associated with the menu item identifier. |
GetLabel | Gets the label associated with a menu item. |
GetLabelTop | Returns the label of a top-level menu. |
GetMenu | Returns the menu at menuIndex (zero-based). |
GetMenuCount | Returns the number of menus in this menubar. |
GetMenuLabel | Returns the label of a top-level menu. |
GetMenuLabelText | Returns the label of a top-level menu. |
GetMenus | GetMenus() -> (menu, label) |
Insert | Inserts the menu at the given position into the menu bar. |
IsAttached | |
IsChecked | Determines whether an item is checked. |
IsEnabled | Determines whether an item is enabled. |
IsEnabledTop | Returns True if the menu with the given index is enabled. |
MacGetCommonMenuBar | Enables you to get the global menubar on Mac, that is, the menubar displayed when the app is running without any frames open. |
MacSetCommonMenuBar | Enables you to set the global menubar on Mac, that is, the menubar displayed when the app is running without any frames open. |
Refresh | Redraw the menu bar. |
Remove | Removes the menu from the menu bar and returns the menu object - the caller is responsible for deleting it. |
Replace | Replaces the menu at the given position with another one. |
SetHelpString | Sets the help string associated with a menu item. |
SetLabel | Sets the label of a menu item. |
SetLabelTop | Sets the label of a top-level menu. |
SetMenuLabel | Sets the label of a top-level menu. |
SetMenus | SetMenus() |
A menu bar is a series of menus accessible from the top of a frame.
Possible constructors:
MenuBar(style=0)
Construct an empty menu bar.
Parameters: | style (long) – If MB_DOCKABLE the menu bar can be detached (wxGTK only). |
---|
Adds the item to the end of the menu bar.
Parameters: | |
---|---|
Return type: | bool |
Returns: | True on success, False if an error occurred. |
See also
Checks or unchecks a menu item.
Parameters: |
|
---|
Note
Only use this when the menu bar has been associated with a frame; otherwise, use the Menu equivalent call.
Enables or disables (greys out) a menu item.
Parameters: |
|
---|
Note
Only use this when the menu bar has been associated with a frame; otherwise, use the Menu equivalent call.
Enables or disables a whole menu.
Parameters: |
|
---|
Note
Only use this when the menu bar has been associated with a frame.
Returns the index of the menu with the given title or NOT_FOUND if no such menu exists in this menubar.
The title parameter may specify either the menu title (with accelerator characters, i.e. "&File" ) or just the menu label ( "File" ) indifferently.
Parameters: | title (string) – |
---|---|
Return type: | int |
Finds the menu item id for a menu name/menu item string pair.
Parameters: |
|
---|---|
Return type: | int |
Returns: | The menu item identifier, or NOT_FOUND if none was found. |
Note
Any special menu codes are stripped out of source and target strings before matching.
Gets the help string associated with the menu item identifier.
Parameters: | id (int) – The menu item identifier. |
---|---|
Return type: | string |
Returns: | The help string, or the empty string if there was no help string or the menu item was not found. |
See also
Gets the label associated with a menu item.
Parameters: | id (int) – The menu item identifier. |
---|---|
Return type: | string |
Returns: | The menu item label, or the empty string if the item was not found. |
Note
Use only after the menubar has been associated with a frame.
Returns the label of a top-level menu.
Note that the returned string does not include the accelerator characters which could have been specified in the menu title string during its construction.
Parameters: | pos (int) – Position of the menu on the menu bar, starting from zero. |
---|---|
Return type: | string |
Returns: | The menu label, or the empty string if the menu was not found. |
Deprecated since version 2.9.4: This function is deprecated in favour of GetMenuLabel and GetMenuLabelText .
Note
Use only after the menubar has been associated with a frame.
See also
Returns the menu at menuIndex (zero-based).
Parameters: | menuIndex (int) – |
---|---|
Return type: | Menu |
Returns the number of menus in this menubar.
Return type: | int |
---|
Returns the label of a top-level menu.
Note that the returned string includes the accelerator characters that have been specified in the menu title string during its construction.
Parameters: | pos (int) – Position of the menu on the menu bar, starting from zero. |
---|---|
Return type: | string |
Returns: | The menu label, or the empty string if the menu was not found. |
Note
Use only after the menubar has been associated with a frame.
See also
Returns the label of a top-level menu.
Note that the returned string does not include any accelerator characters that may have been specified in the menu title string during its construction.
Parameters: | pos (int) – Position of the menu on the menu bar, starting from zero. |
---|---|
Return type: | string |
Returns: | The menu label, or the empty string if the menu was not found. |
Note
Use only after the menubar has been associated with a frame.
See also
GetMenus() -> (menu, label)
Return a list of (menu, label) items for the menus in the MenuBar.
Inserts the menu at the given position into the menu bar.
Inserting menu at position 0 will insert it in the very beginning of it, inserting at position GetMenuCount is the same as calling Append .
Parameters: | |
---|---|
Return type: | bool |
Returns: | True on success, False if an error occurred. |
See also
Return type: | bool |
---|
Determines whether an item is checked.
Parameters: | id (int) – The menu item identifier. |
---|---|
Return type: | bool |
Returns: | True if the item was found and is checked, False otherwise. |
Determines whether an item is enabled.
Parameters: | id (int) – The menu item identifier. |
---|---|
Return type: | bool |
Returns: | True if the item was found and is enabled, False otherwise. |
Returns True if the menu with the given index is enabled.
Parameters: | pos (int) – The menu position (0-based) |
---|---|
Return type: | bool |
New in version 2.9.4.
Enables you to get the global menubar on Mac, that is, the menubar displayed when the app is running without any frames open.
Return type: | MenuBar |
---|---|
Returns: | The global menubar. |
Note
Only exists on Mac, other platforms do not have this method.
Availability
Only available for OSX.
Enables you to set the global menubar on Mac, that is, the menubar displayed when the app is running without any frames open.
Parameters: | menubar (MenuBar) – The menubar to set. |
---|
Note
Only exists on Mac, other platforms do not have this method.
Availability
Only available for OSX.
Redraw the menu bar.
Parameters: |
|
---|
Removes the menu from the menu bar and returns the menu object - the caller is responsible for deleting it.
This function may be used together with Insert to change the menubar dynamically.
Parameters: | pos (int) – |
---|---|
Return type: | Menu |
See also
Replaces the menu at the given position with another one.
Parameters: |
|
---|---|
Return type: | |
Returns: | The menu which was previously at position pos. The caller is responsible for deleting it. |
Sets the help string associated with a menu item.
Parameters: |
|
---|
See also
Sets the label of a menu item.
Parameters: |
|
---|
Note
Use only after the menubar has been associated with a frame.
See also
Sets the label of a top-level menu.
Parameters: |
|
---|
Deprecated since version 2.9.4: This function has been deprecated in favour of SetMenuLabel .
Note
Use only after the menubar has been associated with a frame.
See also
Sets the label of a top-level menu.
Parameters: |
|
---|
Note
Use only after the menubar has been associated with a frame.
SetMenus()
Clear and add new menus to the MenuBar from a list of (menu, label) items.