ttk::menubutton(3tk)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ttk::menubutton β€” the widget that pops off (a menu) when you press it

okay bestie, welcome to the ttk::menubutton page from the Tk Themed Widget manual, section 3tk. she's cute, she's themed, she's literally a button whose whole personality is dropping a menu on you. let's get into it 🫢


✨ NAME ✨

ttk::menubutton β€” the widget that pops down a menu when pressed. that's it. that's her job. and she eats every time πŸ’…


✨ SYNOPSIS ✨

ttk::menubutton pathName ?options?

✨ DESCRIPTION ✨

so a ttk::menubutton widget shows a textual label and/or an image (your choice, or both, live your truth), and when you press it β€” boom β€” she displays a menu. that's the whole vibe. no cap.


✨ STANDARD OPTIONS ✨

these are the classics, the staples, the everyday icons. she's got:

  • -class
  • -compound
  • -cursor
  • -image
  • -state
  • -style
  • -takefocus
  • -text
  • -textvariable
  • -underline
  • -width

want the full lore on any of these? go read the ttk_widget manual entry, she explains everything πŸ’–


✨ WIDGET-SPECIFIC OPTIONS ✨

these are the options that make her her. main character energy only 🌟

πŸŽ€ -direction

  • Command-Line Name: -direction
  • Database Name: direction
  • Database Class: Direction

tells you where the menu pops up relative to the menubutton. pick one of: above, below, left, right, or flush. the default is below. and flush? iconic behaviour β€” she pops the menu up directly over the menubutton, no gap, no chill. 😌

  • Command-Line Name: -menu
  • Database Name: menu
  • Database Class: Menu

this is where you hand her the path name of the menu she's associated with. and listen β€” to be on the safe side, that menu ought to be a direct child of the menubutton. like, keep your friends close and your child widgets closer, fr fr.


✨ WIDGET COMMAND ✨

menubutton widgets come with the standard commands, all of them:

  • cget
  • configure
  • identify element
  • instate
  • state
  • style

(see ttk::widget for the details, she's got the receipts πŸ“œ)


✨ STANDARD STYLES ✨

ttk::menubutton widgets support the Toolbutton style in all standard themes. which is super useful if you're out here creating widgets for toolbars β€” toolbar girlies, this one's for you πŸ› οΈβœ¨


✨ STYLING OPTIONS ✨

the class name for a ttk::menubutton is TMenubutton. remember it, she's famous.

Dynamic states: active, disabled, readonly.

TMenubutton styling options you can configure with ttk::style:

  • -arrowsize amount
  • -background color
  • -compound compound
  • -foreground color
  • -font font
  • -padding padding
  • -relief relief
  • -width amount
heads up bestie: some of these are only available for specific themes πŸ‘€ so don't come for me if one ghosts you in your theme.

for the full tea on configuring ttk styles, check the ttk::style manual page 🌸


✨ SEE ALSO ✨

ttk::widget(3tk), menu(3tk), menubutton(3tk)


✨ KEYWORDS ✨

widget, button, menu


okay that's the whole page, you absolutely ate this reading session πŸ‘‘ go forth and pop those menus πŸ’…

this one's brought to you by Tk 8.5, and yes, she's still serving β€” ttk::menubutton(3tk) forever and always πŸ¦‹βœ¨

πŸ“¦ where this page comes from