class menu_bar.MenuBar(Widget)

The MenuBar class works in conjunction with the Menu class to provide a set of drop-down menus.

A menu bar displays the titles of its attached menus in a horizontal row. Clicking on a menu title causes the associated menu to be displayed, allowing an item to be selected from it.

Menu items are linked to handler methods via command names. When a menu item is invoked, a search is made for a method whose name is the item's command name with '_cmd' appended. The search starts at the widget having the keyboard focus and proceeds up towards to the root widget.

Menu items can be enabled or disabled. Whether an item is enabled is determined by searching for an enabling method whose name is the command name with '_enabled' appended. The search is made along the same path as the search for a handler method. If an enabling method is found, it is called and its boolean result determines whether the item is enabled. If no enabling method is found, the item defaults to being enabled.

A menu item can also be associated with a key combination that includes the platform's standard menu command modifier key (Command on Mac, Control on other platforms). For this to work, the MenuBar must be attached to the menu_bar property of another widget, and that widget must be somewhere on the path from the root widget to the widget having the keyboard focus.

Note that menu command key events are intercepted while being dispatched from the root down to the focus widget, so menu commands will take precedence over any handling of the same events in key_down methods.

See Also

Menu for details of creating menu items and associating them with command names and key combinations.

Widget.menu_bar for attaching the menu bar to a widget.


Creates a menu bar. The height defaults to the font height. If you don't specify a width, it will be set automatically when the menu bar is assigned to the menu_bar property of a widget.


A list of Menu instances.