Web Analytics Made Easy - Statcounter
Skip to content

Menu

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.

Menu(
    menu_definition,
    background_color = "1234567890",
    text_color = None,
    size = (None, None),
    tearoff = False,
    pad = None,
    key = None,
    disabled = False,
    font = None
)

Parameter Descriptions

Name Type Default Description
background_color str 1234567890 color of the background of menus, NOT the Menubar. Can be in #RRGGBB format or a color name "black"
disabled bool False disable or enable state of the element
font (str or (str, int[, str]) or None) None specifies the font family, size. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
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) 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
text_color str None element's text color. Can be in #RRGGBB format or a color name "black"

Class Properties

This class has no public properties

Class Methods

 def update

update

Updates the element

update(
    widget,
    background_color = None,
    text_color = None,
    font = None,
    visible = None,
    disabled = None,
    tooltip = None
)

Parameter Descriptions

Name Type Default Description
background_color str None color of background. Can be in #RRGGBB format or a color name "black"
disabled bool None Is the element disabled
font (str or (str, int[, str]) or None) None specifies the font family, size. Tuple or Single string format 'name size styles'. Styles: italic * roman bold normal underline overstrike
text_color None Text color
tooltip None Tooltip to be shown
visible bool None Is the element visible
widget The widget to be updated