ttk::checkbutton(n)

πŸ“¦
version 9.0.3 Β· 3 versions
, in alpine 3.23, alpine 3.24, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸ’– ttk::checkbutton(n) β€” the Tk Themed Widget πŸ’–

✨ NAME ✨

ttk::checkbutton β€” the iconic on/off widget, no cap ✨

🌈 SYNOPSIS 🌈

ttk::checkbutton pathName ?options?

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so bestie, a ttk::checkbutton widget is literally what you use to show or change a setting. It's got two states: selected and deselected. And the state of the checkbutton may be linked to a Tcl variable. It's giving "toggle queen" energy. πŸ’…

πŸŽ€ STANDARD OPTIONS πŸŽ€

The standard options are -class, -compound, -cursor, -image, -state, -style, -takefocus, -text, -textvariable, -underline, and -width. See the ttk_widget manual entry for details on the standard options. ✨

πŸ‘‘ WIDGET-SPECIFIC OPTIONS πŸ‘‘

  • -command β€” A Tcl script to execute whenever the widget is invoked. (Database name: command, database class: Command) πŸ’₯
  • -offvalue β€” The value to store in the associated -variable when the widget is deselected. Defaults to 0. (Database name: offValue, database class: OffValue) πŸ™ˆ
  • -onvalue β€” The value to store in the associated -variable when the widget is selected. Defaults to 1. (Database name: onValue, database class: OnValue) πŸ”₯
  • -variable β€” The name of a global variable whose value is linked to the widget. Defaults to the widget pathname if not specified. (Database name: variable, database class: Variable) 🫢

πŸ’€ WIDGET COMMAND πŸ’€

In addition to the standard cget, configure, identify element, instate, state and style commands (see ttk::widget), checkbutton widgets support the following additional commands:

  • pathname invoke β€” Toggles between the selected and deselected states and evaluates the associated -command. If the widget is currently selected, sets the -variable to the -offvalue and deselects the widget; otherwise, sets the -variable to the -onvalue. Returns the result of the -command. πŸ’«

🧚 WIDGET STATES 🧚

  • The widget does not respond to user input if the disabled state is set. 🚫
  • The widget sets the selected state whenever the linked -variable is set to the widget's -onvalue, and clears it otherwise. βœ…
  • The widget sets the alternate state whenever the linked -variable is unset. πŸŒ—
The alternate state may be used to indicate a "tri-state" or "indeterminate" selection. πŸ’­

🌸 STANDARD STYLES 🌸

Ttk::checkbutton widgets support the Toolbutton style in all standard themes, which is useful for creating widgets for toolbars. πŸ› οΈ

πŸ“ STYLING OPTIONS πŸ“

The class name for a ttk::checkbutton is TCheckbutton. 🏷️

Dynamic states: active, alternate, disabled, pressed, selected, readonly. ✨

TCheckbutton styling options configurable with ttk::style are:

  • -background color
  • -compound compound
  • -foreground color
  • -indicatorbackground color
  • -indicatorcolor color
  • -indicatormargin padding
  • -indicatorrelief relief
  • -padding padding

Some options are only available for specific themes. πŸ™ˆ

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

πŸ”— SEE ALSO πŸ”—

ttk::widget(n), ttk::radiobutton(n), checkbutton(n) πŸ‘€

⭐ KEYWORDS ⭐

widget, button, toggle, check, option πŸ’…


This page is from Tk 8.5, bestie! Stay toggling! πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from