ttk::button(3tk)

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

πŸ’– ttk::button β€” the manual, but make it cute πŸ’–

okay bestie, welcome to ttk::button, part of the Tk Themed Widget fam (that's the 3tk manual section, iykyk). this is the widget that's literally just a button. you press it. it does a thing. main character energy fr fr. πŸŽ€


✨ NAME ✨

ttk::button β€” the widget that issues a command when pressed. that's it. that's the whole job. and it ate. πŸ’…


✨ SYNOPSIS ✨

ttk::button pathName ?options?

✨ DESCRIPTION ✨

so a ttk::button widget shows a textual label and/or an image, and then β€” the moment of truth β€” it evaluates a command when pressed. that's the vibe. you click, it slays. πŸ¦‹


✨ STANDARD OPTIONS ✨

these are the standard ones, all chill and shared with the rest of the ttk crew:

  • -class
  • -compound
  • -cursor
  • -image
  • -justify
  • -state-style
  • -takefocus
  • -text
  • -textvariable
  • -underline
  • -width
ngl if you want the tea on what each of these actually does, go read the ttk_widget manual entry. it's all there, bestie. πŸ’œ

✨ WIDGET-SPECIFIC OPTIONS ✨

these are the options that are hers. the ones only button gets to have. periodt. πŸ‘‘

🌸 -command

  • Command-Line Name: -command
  • Database Name: command
  • Database Class: Command

a script to evaluate when the widget is invoked. that's the "does the thing when you click" option. the whole point, honestly.

🌸 -default

  • Command-Line Name: -default
  • Database Name: default
  • Database Class: Default

this one can be set to one of normal, active, or disabled. so here's the lore: in a dialog box, one button may be designated the "default" button β€” which roughly means "the one that gets invoked when the user presses <Enter>". πŸ’…

  • active = this is currently the default button, she's the moment
  • normal = she may become the default button, she's keeping her options open
  • disabled = not defaultable, sorry bestie, not her era

the default is normal.

depending on the theme, the default button may be displayed with an extra highlight ring, or with a different border color. so she gets a little sparkle. ✨


✨ WIDGET COMMAND ✨

on top of the standard cget, configure, identify element, instate, state and style commands (peep the ttk::widget manual for those), button widgets also support this extra one:

  • pathName invoke β€” invokes the command associated with the button. it's literally just pressing the button with your code. no mouse required. iconic.

✨ STANDARD STYLES ✨

Ttk::button widgets support the Toolbutton style in all standard themes, which is useful for creating widgets for toolbars. handy for when you're building a toolbar and need that look. πŸ› οΈ

in the Aqua theme there are several other styles which can be used to produce replicas of many of the different button types that are discussed in Apple's Human Interface Guidelines. these include:

  • DisclosureButton
  • DisclosureTriangle
  • HelpButton
  • ImageButton
  • InlineButton
  • GradientButton
  • RoundedRectButton
  • RecessedButton

like okay Apple, we see you. 😭✨


✨ STYLING OPTIONS ✨

the class name for a ttk::button is TButton. remember that, it matters.

Dynamic states: active, disabled, pressed, readonly.

TButton styling options configurable with ttk::style are:

  • -anchor anchor
  • -background color
  • -bordercolor color
  • -compound compound
  • -darkcolor color
  • -foreground color
  • -font font
  • -highlightcolor color
  • -highlightthickness amount
  • -lightcolor color
  • -padding padding
  • -relief relief
  • -shiftrelief amount
    • -shiftrelief specifies how far the button contents are shifted down and right in the pressed state. this action provides additional skeuomorphic feedback. yes she moves when you press her, that's the tactile little moment 🫢
  • -width amount
heads up: some options are only available for specific themes. don't come for me if your theme doesn't have them, that's just how it is bestie.

see the ttk::style manual page for information on how to configure ttk styles. πŸ’–


✨ SEE ALSO ✨


✨ KEYWORDS ✨

widget, button, default, command


and that's the whole page, bestie! 🌈 this one's from Tk 8.5, and it's the ttk::button(3tk) manual β€” go forth and press buttons, you absolute icon. no cap. πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from