ttk::radiobutton(3tk)

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

πŸ’– ttk::radiobutton β€” the Tk Themed Widget era πŸ’–

okay bestie, welcome to ttk::radiobutton(3tk), one of the Tk themed widgets. yes we're in the manual pages, no it's not boring, stay with me 🫢


✨ NAME ✨

ttk::radiobutton β€” mutually exclusive option widget

like, the whole point is that only ONE of them can be picked at a time. iconic behavior honestly πŸ‘‘


🌸 SYNOPSIS 🌸

ttk::radiobutton pathName ?options?

πŸ’… DESCRIPTION πŸ’…

so ttk::radiobutton widgets roll in groups, and the group is there to show or change a set of mutually-exclusive options β€” meaning picking one un-picks the others, no drama, no overlap, we love a clean system πŸ’–

Each radiobutton is linked to a Tcl variable, and it has an associated value. When you click a radiobutton, it sets that variable to its associated value. that's the whole move. that's the vibe. ✨


πŸŽ€ STANDARD OPTIONS πŸŽ€

  • -class
  • -compound
  • -cursor
  • -image
  • -state
  • -style
  • -takefocus
  • -text
  • -textvariable
  • -underline
  • -width
head over to the ttk_widget manual entry if you want the deets on all the standard options, bestie. i'm not gonna re-explain the classics πŸ’œ

πŸ¦‹ WIDGET-SPECIFIC OPTIONS πŸ¦‹

okay these are the ones that make radiobuttons radiobuttons, pay attention 😌

  • -command (Command-Line Name: -command; Database Name: command; Database Class: Command) β€” a Tcl script to evaluate whenever the widget is invoked. like, every single time. it's giving "reactive" πŸ”₯
  • -value (Command-Line Name: -value; Database Name: Value; Database Class: Value) β€” the value that gets stored in the associated -variable when the widget is selected. this is literally the thing that makes it this option and not the other ones 🌈
  • -variable (Command-Line Name: -variable; Database Name: variable; Database Class: Variable) β€” the name of a global variable whose value is linked to the widget. default value is ::selectedButton. yes, that's the default, no cap πŸ’€

πŸ’œ WIDGET COMMAND πŸ’œ

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

  • pathname invoke β€” sets the -variable to the -value, selects the widget, and evaluates the associated -command. It returns the result of the -command, or the empty string if no -command is specified.

so like, invoke does the whole click experience for you. three-for-one special ✨


🌟 WIDGET STATES 🌟

  • If the disabled state is set, the widget does not respond to user input. it's offline. do not perceive it πŸ™ˆ
  • The widget sets the selected state whenever the linked -variable is set to the widget's -value, 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.) it's giving "idk yet" energy 😭

πŸ‘‘ STANDARD STYLES πŸ‘‘

Ttk::radiobutton widgets support the Toolbutton style in all standard themes β€” which is super useful for creating widgets for toolbars. toolbar besties, this one's for you 🫢


πŸ“ STYLING OPTIONS πŸ“

The class name for a ttk::radiobutton is TRadiobutton.

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

TRadiobutton 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, so if one of these ghosts you, it's not you, it's the theme πŸ’€

see the ttk::style manual page for info on how to configure ttk styles ✨


🌈 SEE ALSO 🌈


⭐ KEYWORDS ⭐

widget, button, option


and that's the whole page, bestie πŸ’– this one's from Tk 8.5 β€” the ttk::radiobutton(3tk) page β€” so go forth, group your radiobuttons, set your -variable, and pick exactly one option like the main character you are πŸ‘‘πŸ’… periodt.

πŸ“¦ where this page comes from