Web Analytics Made Easy - Statcounter
Skip to content

ButtonMenu

ButtonMenu call reference

The ButtonMenu element produces a unique kind of effect. It's a button, that when clicked, shows you a menu. It's like clicking one of the top-level menu items on a MenuBar. As a result, the menu definition take the format of a single menu entry from a normal menu definition.

layout = [[sg.ButtonMenu('not used',  ['Menu', ['Menu item 1::optional_key', 'Menu item 2']])]]

The very first string normally specifies what is shown on the menu bar. In this case, the value is not used. You set the text for the button using a different parameter, the button_text parm.

One use of this element is to make a "fake menu bar" that has a colored background. Normal menu bars cannot have their background color changed. Not so with ButtonMenus.

This element was used to create the MenubarCustom element.

Events

When a selection is make from a ButtonMenu, an event is generated that matches the key of the ButtonMenu element

Values Dictionary

When a selection is made is the complete string for that menu item, including the optional menu item key, is in the values dictionary.

See the section on Menus for the format of menu definitions.