Skip to main content
Ctrl+K
Building a whole app, not just theming one? Try bootstack →
ttkbootstrap ttkbootstrap
  • User Guide
  • Widgets
  • Reference
  • Themes
  • Release notes
  • About
  • GitHub
  • User Guide
  • Widgets
  • Reference
  • Themes
  • Release notes
  • About
  • GitHub
  • Widgets
    • Button
    • Menubutton
    • OptionMenu
    • Menu
    • Entry
    • Spinbox
    • Combobox
    • DateEntry
    • Text
    • Checkbutton
    • Radiobutton
    • Listbox
    • Scale
    • LabeledScale
    • Progressbar
    • Meter
    • Floodgauge
    • Treeview
    • Tableview
    • Frame
    • Labelframe
    • Notebook
    • Panedwindow
    • Scrollbar
    • Separator
    • Sizegrip
    • Tk
    • TkFrame
    • Label
    • TkLabel
    • Canvas
  • Windows
    • App
    • Toplevel
  • Dialogs & overlays
    • Messagebox
    • Querybox
    • Dialog classes
    • Pickers
    • ToastNotification
    • ToolTip
  • Styling
  • Theming
  • Imaging
  • Localization
  • Fonts
  • Validation
  • Variables
  • Geometry
    • Pack
    • Grid
    • Place
    • Stacking order
  • Utilities
  • Capabilities
    • Configuration
    • Bind
    • Focus
    • Grab
    • After
    • Lifecycle
    • Clipboard
    • Selection
    • Busy
    • Interpreter
    • Widget & screen info
  • Events
    • Event types
    • Modifiers & keys
    • The event object
    • event_generate options
    • Built-in virtual events
  • Cursors
  • Reference
  • Widgets
  • Menu

Menu#

Menu is tkinter’s menu widget (tk.Menu), themed by ttkbootstrap and re-exported as ttk.Menu. It backs menu bars, cascading submenus, and right-click context menus; ttkbootstrap adds helpers for the native macOS application menu. Entries are addressed by integer index (0-based) or the special index "end" / "active" / "last". This page is the complete reference for its own options and methods; the shared widget methods are under Capabilities.

Options#

Option

Type

Description

autostyle

bool

Constructor only. True (default) paints the menu with the active theme and repaints on a theme switch; False opts out.

font

str | Font

The font for entry labels.

foreground (fg)

str

The text color of entries.

background (bg)

str

The menu background color.

activeforeground

str

The text color of the entry under the pointer.

activebackground

str

The background color of the entry under the pointer.

activeborderwidth

int

The border width of the entry under the pointer, in pixels.

disabledforeground

str

The text color of disabled entries.

selectcolor

str

The indicator color of checkbutton / radiobutton entries.

borderwidth (bd)

int

The 3-D border width in pixels.

relief

str

The border style: "flat", "raised", "sunken", "groove", "ridge", or "solid".

tearoff

bool

True adds a dashed line that tears the menu into a floating window.

tearoffcommand

callable

A callback invoked when the menu is torn off.

postcommand

callable

A callback invoked just before the menu is posted — use it to update entries lazily.

title

str

The title shown on a torn-off menu.

type

str

The menu flavor: "normal", "menubar", or "tearoff". Set when the menu is created; changing it later has no effect.

cursor

str

The mouse cursor over the menu (see Cursors).

takefocus

bool

Whether the menu accepts keyboard focus during traversal.

Methods#

Adding entries#

Every add_* appends an entry; the parallel insert_* methods take a leading index and insert before it.

add_command(**options)

Append a command entry.

Parameters:

options – label, command, accelerator (shown shortcut text), underline, state, image, compound.

Returns:

None.

add_cascade(**options)

Append a submenu entry.

Parameters:

options – label and menu (a child Menu), plus underline, state.

Returns:

None.

add_checkbutton(**options)

Append a checkbutton entry that toggles a variable.

Parameters:

options – label, variable, onvalue, offvalue, command.

Returns:

None.

add_radiobutton(**options)

Append a radiobutton entry — one choice in a group sharing a variable.

Parameters:

options – label, variable, value, command.

Returns:

None.

add_separator(**options)

Append a horizontal separator line.

Returns:

None.

insert(index, itemType, **options)

Insert an entry of itemType ("command", "cascade", "checkbutton", "radiobutton", "separator") before index. The insert_command / insert_cascade / insert_checkbutton / insert_radiobutton / insert_separator shortcuts wrap this, and add(itemType, **options) is the appending equivalent that the add_* shortcuts wrap.

Returns:

None.

Configuring and removing entries#

entryconfigure(index, **options)

Set (or query) options on an existing entry. Alias: entryconfig.

Parameters:
  • index – the entry to change.

  • options – any options valid for that entry type.

Returns:

the option spec when queried with a single option name, else None.

entrycget(index, option)

Return one option of an entry.

delete(index1, index2=None)

Delete an entry, or a range of entries.

Returns:

None.

index(index)

Resolve an index expression to an integer entry number.

Return type:

int

type(index)

Return the type of an entry — "command", "cascade", "checkbutton", "radiobutton", "separator", or "tearoff".

Return type:

str

Posting and invoking#

tk_popup(x, y, entry='')

Pop the menu up as a context menu at a screen position — the usual way to show a right-click menu.

Parameters:
  • x (int) – screen x, in pixels.

  • y (int) – screen y, in pixels.

  • entry – an entry to position under the pointer.

Returns:

None.

post(x, y)

Map the menu at a screen position (lower-level than tk_popup).

Returns:

None.

unpost()

Unmap the menu.

Returns:

None.

invoke(index)

Invoke the action of an entry as if the user chose it.

Returns:

the value returned by the entry’s command, if any.

activate(index)

Highlight an entry as the active one.

Returns:

None.

xposition(index)

Return the x pixel coordinate of an entry within the menu; yposition(index) is the vertical counterpart.

Return type:

int

macOS application menu (ttkbootstrap)#

These ttkbootstrap additions wire a menu bar into the native macOS menu conventions. Each is a no-op off macOS, so the same code runs everywhere.

add_application_menu()

Add and return the macOS application menu — the bold, app-named menu that owns About, Preferences…, and Quit.

Returns:

the application menu, or None off macOS.

Return type:

Menu | None

add_window_menu(label='Window')

Add and return the macOS standard Window menu.

Returns:

the Window menu, or None off macOS.

Return type:

Menu | None

add_help_menu(label='Help', command=None)

Add and return a Help menu, wired into the macOS Help conventions.

Parameters:

command – a callback for the search/help action.

Returns:

the Help menu, or None off macOS.

Return type:

Menu | None

on_preferences(callback)

Enable the macOS Preferences… item (⌘,) and call callback when it is chosen. Requires add_application_menu().

Returns:

None.

on_quit(callback)

Call callback when the user chooses macOS Quit (⌘Q). Requires add_application_menu().

Returns:

None.

Shared capabilities#

Menu also has the methods every widget inherits — configuration, event binding, lifecycle, and introspection. These are documented under Capabilities.

See also#

  • Menus — the usage guide.

  • Tk menu manual page — the canonical upstream reference (Tcl 8.6).

previous

OptionMenu

next

Entry

On this page
  • Options
  • Methods
    • Adding entries
    • Configuring and removing entries
    • Posting and invoking
    • macOS application menu (ttkbootstrap)
  • Shared capabilities
  • See also

© Copyright 2026, Israel Dryer.

Created using Sphinx 9.1.0.

Built with the PyData Sphinx Theme 0.20.0.