Web Analytics Made Easy - Statcounter
Skip to content

MenubarCustom

MenubarCustom call reference

Like the titlebar, the menubar is normally created by the operating system. As a result, changing the colors, font, etc, are not possible in some cases. If you want your menubar to match your window's theme, then you can use this element to get the right colors.

If you use a Titlebar element in your layout, then you must use the MenubarCustom element if you want a menubar.

The Menubar will be themed according to your current theme's colors. The theme's button colors are used. All of the colors can be changed from the menubar to the menu's text an background.

The overall operation of the element is similar to the Menu element.

menu_def = [['&File', ['!&Open', '&Save::savekey', '---', '&Properties', 'E&xit']], ['&Help', ['&About...']]]

layout = [[sg.MenubarCustom(menu_def)],
          [sg.Text('Your window!', size=(30, 5))]]

Events

The MenubarCustom element creates events that looks identical to how the Menu element works.

Values Dictionary

When a MenubarCustom element generates an event, the Values Dictionary will contain the same information as the event.

This allows you to determine exactly which element caused the event.

Pseudo-Element Limitations

Because this element is a pseudo-element, at the moment, you cannot perform all of the same operations using this custom menubar that you can with a traditional menubar. Modifying the menu isn't possible yet. In other words, it's a great start, but more work is needed such as adding an update method, etc.

Shortcuts are possible within the menus, but not for the initial selection.