Skip to content

MenuButton

MenuButton is a menu-first control: it displays like a button, but its primary purpose is to open a Tk menu. Use it for classic menu patterns (File/Edit/View), or when the options list is the main interaction.


Quick start

MenuButton uses a standard Tk Menu.

import bootstack as bs
from tkinter import Menu

app = bs.App()

m = Menu(app, tearoff=0)
m.add_command(label="Open", command=lambda: print("Open"))
m.add_command(label="Save", command=lambda: print("Save"))
m.add_separator()
m.add_command(label="Exit", command=app.destroy)

bs.MenuButton(app, text="File", menu=m).pack(padx=20, pady=20)

app.mainloop()

When to use

Use MenuButton when:

  • the control is primarily a menu entry point
  • you need native-style menu behavior (keyboard navigation, platform conventions)
  • your menu items map well to Tk’s Menu model

Consider a different control when…

  • you want a primary action plus a small menu → use DropdownButton
  • you want a fully themed, widget-backed menu with icons/layout → use ContextMenu
  • you want a single action → use Button

Appearance

MenuButton supports semantic colors and variants through accent and variant.

bs.MenuButton(app, text="Menu", accent="primary").pack(pady=4)
bs.MenuButton(app, text="Menu", accent="primary", variant="outline").pack(pady=4)

Behavior

  • MenuButton opens the associated Tk Menu.
  • Menu keyboard navigation and platform conventions are handled by Tk.

Localization

Tk Menu labels can be localized by passing message tokens (or resolved strings) when you build the menu.

m = Menu(app, tearoff=0)
m.add_command(label="menu.open", command=lambda: ...)
bs.MenuButton(app, text="button.file", menu=m).pack()

Additional resources

Framework concepts

API reference