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

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"
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)
pad (int, int or (int, int),(int,int) or int,(int,int)) or ((int, int),int) or 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

Class Properties

This class has no public properties

Class Methods

 def update


Updates the element

    background_color = None,
    text_color = None,
    font = None,
    visible = None,
    disabled = None,
    tooltip = None

Parameter Descriptions

Name Type Default Description
background_color None Widget background color
disabled bool None Is the element disabled
font None Text font
text_color None Text color
tooltip None Tooltip to be shown
visible bool None Is the element visible
widget The widget to be updated