ttk::checkbutton(3tk)
β¨ ttk::checkbutton β¨
okay bestie, welcome to the ttk::checkbutton page from the Tk Themed Widget manual β it's an on/off widget and it's literally the most iconic little toggle in the game π
πΈ NAME πΈ
ttk::checkbutton β the on/off widget. that's it. that's the whole job. and it ate.
π SYNOPSIS π
ttk::checkbutton pathName ?options?
π¦ DESCRIPTION π¦
so a ttk::checkbutton widget is what you use to show or change a setting. it's giving very demure, very mindful: two states, selected and deselected, and nothing else. no drama.
and here's the cute part β the state of the checkbutton can be linked to a Tcl variable. so the widget and your variable are basically in a situationship that actually works π«Ά
β STANDARD OPTIONS β
these ones are inherited from the whole ttk widget family, and they are:
-class-compound-cursor-image-state-style-takefocus-text-textvariable-underline-width
for the full tea on all of these, go read the ttk_widget manual entry. she explains them way better than i could in a single bullet. π
π WIDGET-SPECIFIC OPTIONS π
these are the options that are hers. hers specifically. nobody else's.
-command
- Command-Line Name:
-command - Database Name:
command - Database Class:
Command
a Tcl script to execute whenever the widget is invoked. that's the whole vibe β you click, she runs.
-offvalue
- Command-Line Name:
-offvalue - Database Name:
offValue - Database Class:
OffValue
the value that gets stored in the associated -variable when the widget is deselected. defaults to 0. yes, 0. classic.
-onvalue
- Command-Line Name:
-onvalue - Database Name:
onValue - Database Class:
OnValue
the value that gets stored in the associated -variable when the widget is selected. defaults to 1. slay.
-variable
- Command-Line Name:
-variable - Database Name:
variable - Database Class:
Variable
the name of a global variable whose value is linked to the widget. if you don't specify one, it defaults to the widget's pathname. so she'll just use her own name, main character energy fr fr π
π WIDGET COMMAND π
okay so in addition to the standard cget, configure, identify element, instate, state and style commands (peep ttk::widget for those), checkbutton widgets also support this extra one:
pathname invokeβ toggles between the selected and deselected states and evaluates the associated-command. if the widget is currently selected, it sets the-variableto the-offvalueand deselects the widget; otherwise, it sets the-variableto the-onvalue. it returns the result of the-command. π«
π WIDGET STATES π
- if the disabled state is set, the widget does not respond to user input. periodt.
- the widget sets the selected state whenever the linked
-variableis set to the widget's-onvalue, and clears it otherwise. - the widget sets the alternate state whenever the linked
-variableis unset.
the alternate state is the one you use to show a "tri-state" or "indeterminate" selection, if you're feeling fancy. πΈ
π§ STANDARD STYLES π§
Ttk::checkbutton widgets support the Toolbutton style in all standard themes, which is super handy if you're building widgets for toolbars. iykyk β¨
π STYLING OPTIONS π
the class name for a ttk::checkbutton is TCheckbutton. noted.
Dynamic states: active, alternate, disabled, pressed, selected, readonly.
the TCheckbutton styling options you can configure with ttk::style are:
-backgroundcolor-compoundcompound-foregroundcolor-indicatorbackgroundcolor-indicatorcolorcolor-indicatormarginpadding-indicatorreliefrelief-paddingpadding
ngl, some of these options are only available for specific themes. so if one isn't working, it's not you, it's the theme. π
for the full how-to on configuring ttk styles, go read the ttk::style manual page. she's the blueprint.
π«Ά SEE ALSO π«Ά
ttk::widget(3tk)ttk::radiobutton(3tk)checkbutton(3tk)
π KEYWORDS π
widget, button, toggle, check, option
and that's the whole page bestie!! ate and left no crumbs π
this was Tk version 8.5, and yeah the page is ttk::checkbutton(3tk) β go toggle something, you got this π
π¦ where this page comes from
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 2004 Joe English
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms