Web Analytics Made Easy - Statcounter
Skip to content


Menu Element is the Element that provides a Menu Bar that goes across the top of the window, just below titlebar. Here is an example layout. The "&" are shortcut keys ALT+key. Is a List of - "Item String" + List Where Item String is what will be displayed on the Menubar itself. The List that follows the item represents the items that are shown then Menu item is clicked Notice how an "entry" in a mennu can be a list which means it branches out and shows another menu, etc. (resursive) menu_def = [['&File', ['!&Open', '&Save::savekey', '---', '&Properties', 'E&xit']], ['!&Edit', ['!&Paste', ['Special', 'Normal', ], 'Undo'], ], ['&Debugger', ['Popout', 'Launch Debugger']], ['&Toolbar', ['Command &1', 'Command &2', 'Command &3', 'Command &4']], ['&Help', '&About...'], ] Important Note! The colors, font, look of the Menubar itself cannot be changed, only the menus shown AFTER clicking the menubar can be changed. Finally, "keys" can be added to entries so make them unique. The "Save" entry has a key associated with it. You can see it has a "::" which signifies the beginning of a key. The user will not see the key portion when the menu is shown. The key portion is returned as part of the event.

    background_color = None,
    size = (None, None),
    tearoff = False,
    pad = None,
    key = None,
    k = None,
    visible = True,
    metadata = None

Parameter Descriptions

Name Type Default Description
background_color str None color of the background of menus, NOT the Menubar. Can be in #RRGGBB format or a color name "black"
k str or int or tuple or object None Same as the Key. You can use either k or key. Which ever is set will be used.
key str or int or tuple or object None Value that uniquely identifies this element from all other elements. Used when Finding an element or in return values. Must be unique to the window
menu_definition List[List[Tuple[str, List[str]]] The Menu definition specified using lists (docs explain the format)
metadata Any None User metadata that can be set to ANYTHING
pad (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) None Amount of padding to put around element in pixels (left/right, top/bottom) or ((left, right), (top, bottom)) or an int. If an int, then it's converted into a tuple (int, int)
size (int, int) (None, None) Not used in the tkinter port
tearoff bool False if True, then can tear the menu off from the window ans use as a floating window. Very cool effect
visible bool True set visibility state of the element (Default = True)

Class Properties

This class has no public properties

Class Methods

 def expand
 def get_stylesheet
 def set_stylesheet
 def update


WARNING - NOT USED IN PySimpleGUIQt port. Provided as dummy method

    expand_x = False,
    expand_y = False,
    expand_row = True

Parameter Descriptions

Name Type Default Description
expand_row bool True If True the row containing the element will also expand. Without this your element is "trapped" within the row
expand_x bool False If True Element will expand in the Horizontal directions
expand_y bool False If True Element will expand in the Vertical directions
RETURN None None


Returns the stylesheet for element's associated Qt Widget


Parameter Descriptions

Name Type Default Description
RETURN str stylesheet


Sets the stylesheet for a Qt Widget


Parameter Descriptions

Name Type Default Description
stylesheet str Stylesheet (string) to set stylesheet to


Update a menubar - can change the menu definition and visibility. The entire menu has to be specified

Changes will not be visible in your window until you call window.read or window.refresh.

If you change visibility, your element may MOVE.

    menu_definition = None,
    visible = None

Parameter Descriptions

Name Type Default Description
menu_definition List[List[Tuple[str, List[str]]] None The menu definition list
visible bool None control visibility of element