1radiobutton(n)               Tk Built-In Commands               radiobutton(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       radiobutton - Create and manipulate 'radiobutton' pick-one widgets
9

SYNOPSIS

11       radiobutton pathName ?options?
12

STANDARD OPTIONS

14       -activebackground     -disabledforeground  -padx
15       -activeforeground     -font                -pady
16       -anchor               -foreground          -relief
17       -background           -highlightbackground -takefocus
18       -bitmap               -highlightcolor      -text
19       -borderwidth          -highlightthickness  -textvariable
20       -compound             -image               -underline
21       -cursor               -justify             -wraplength
22
23       See the options manual entry for details on the standard options.
24

WIDGET-SPECIFIC OPTIONS

26       Command-Line Name:-command
27       Database Name:  command
28       Database Class: Command
29
30              Specifies a Tcl command to associate with the button.  This com‐
31              mand is typically invoked when mouse button 1 is  released  over
32              the  button  window.   The  button's  global variable (-variable
33              option) will be updated before the command is invoked.
34
35       Command-Line Name:-height
36       Database Name:  height
37       Database Class: Height
38
39              Specifies a desired height for the button.  If an image or  bit‐
40              map is being displayed in the button then the value is in screen
41              units (i.e. any of the forms acceptable  to  Tk_GetPixels);  for
42              text  it  is in lines of text.  If this option is not specified,
43              the button's desired height is computed from  the  size  of  the
44              image or bitmap or text being displayed in it.
45
46       Command-Line Name:-indicatoron
47       Database Name:  indicatorOn
48       Database Class: IndicatorOn
49
50              Specifies whether or not the indicator should be drawn.  Must be
51              a proper boolean value.  If false, the -relief option is ignored
52              and  the  widget's  relief  is  always  sunken  if the widget is
53              selected and raised otherwise.
54
55       Command-Line Name:-offrelief
56       Database Name:  offRelief
57       Database Class: OffRelief
58
59              Specifies the relief for the checkbutton when the  indicator  is
60              not  drawn  and  the  checkbutton  is off.  The default value is
61              “raised”.  By setting this option to “flat” and setting -indica‐
62              toron  to  false  and  -overrelief  to  “raised”,  the effect is
63              achieved of having a flat button that raises on  mouse-over  and
64              which  is  depressed when activated.  This is the behavior typi‐
65              cally exhibited  by  the  Align-Left,  Align-Right,  and  Center
66              radiobuttons on the toolbar of a word-processor, for example.
67
68       Command-Line Name:-overrelief
69       Database Name:  overRelief
70       Database Class: OverRelief
71
72              Specifies  an alternative relief for the radiobutton, to be used
73              when the mouse cursor is over the widget.  This  option  can  be
74              used to make toolbar buttons, by configuring -relief flat -over‐
75              relief raised.  If the value of this option is the empty string,
76              then no alternative relief is used when the mouse cursor is over
77              the radiobutton.  The empty string is the default value.
78
79       Command-Line Name:-selectcolor
80       Database Name:  selectColor
81       Database Class: Background
82
83              Specifies a background color to use when the button is selected.
84              If -indicatoron is true then the color applies to the indicator.
85              Under Windows, this color is used  as  the  background  for  the
86              indicator  regardless  of  the select state.  If -indicatoron is
87              false, this color is used as the background for the entire  wid‐
88              get,  in place of -background or -activeBackground, whenever the
89              widget is selected.  If specified as an  empty  string  then  no
90              special  color  is  used  for  displaying  when  the  widget  is
91              selected.
92
93       Command-Line Name:-selectimage
94       Database Name:  selectImage
95       Database Class: SelectImage
96
97              Specifies an image to display (in place of  the  -image  option)
98              when the radiobutton is selected.  This option is ignored unless
99              the -image option has been specified.
100
101       Command-Line Name:-state
102       Database Name:  state
103       Database Class: State
104
105              Specifies one of three  states  for  the  radiobutton:   normal,
106              active,  or  disabled.   In normal state the radiobutton is dis‐
107              played using  the  -foreground  and  -background  options.   The
108              active  state  is  typically  used  when the pointer is over the
109              radiobutton.  In active state the radiobutton is displayed using
110              the  -activeforeground  and -activebackground options.  Disabled
111              state means that the radiobutton  should  be  insensitive:   the
112              default  bindings  will  refuse  to activate the widget and will
113              ignore mouse button presses.  In this state  the  -disabledfore‐
114              ground  and -background options determine how the radiobutton is
115              displayed.
116
117       Command-Line Name:-tristateimage
118       Database Name:  tristateImage
119       Database Class: TristateImage
120
121              Specifies an image to display (in place of  the  -image  option)
122              when the radiobutton is selected.  This option is ignored unless
123              the -image option has been specified.
124
125       Command-Line Name:-tristatevalue
126       Database Name:  tristateValue
127       Database Class: Value
128
129              Specifies the value that causes the radiobutton to  display  the
130              multi-value   selection,  also  known  as  the  tri-state  mode.
131              Defaults to “”.
132
133       Command-Line Name:-value
134       Database Name:  value
135       Database Class: Value
136
137              Specifies value to store in  the  button's  associated  variable
138              whenever this button is selected.
139
140       Command-Line Name:-variable
141       Database Name:  variable
142       Database Class: Variable
143
144              Specifies  the  name  of  a global variable to set whenever this
145              button is selected.  Changes in this  variable  also  cause  the
146              button  to  select  or  deselect  itself.  Defaults to the value
147              selectedButton.
148
149       Command-Line Name:-width
150       Database Name:  width
151       Database Class: Width
152
153              Specifies a desired width for the button.  If an image or bitmap
154              is  being  displayed in the button, the value is in screen units
155              (i.e. any of the forms acceptable to Tk_GetPixels); for text  it
156              is in characters.  If this option is not specified, the button's
157              desired width is computed from the size of the image  or  bitmap
158              or text being displayed in it.
159______________________________________________________________________________
160

DESCRIPTION

162       The  radiobutton  command  creates  a new window (given by the pathName
163       argument) and makes it into a radiobutton widget.  Additional  options,
164       described  above, may be specified on the command line or in the option
165       database to configure aspects of the radiobutton such  as  its  colors,
166       font,  text,  and  initial relief.  The radiobutton command returns its
167       pathName argument.  At the time this command is invoked, there must not
168       exist a window named pathName, but pathName's parent must exist.
169
170       A  radiobutton  is  a  widget that displays a textual string, bitmap or
171       image and a diamond or circle called an indicator.   If  text  is  dis‐
172       played,  it  must  all  be in a single font, but it can occupy multiple
173       lines on the screen (if it contains  newlines  or  if  wrapping  occurs
174       because  of  the  -wraplength  option)  and  one  of the characters may
175       optionally be underlined using the -underline  option.   A  radiobutton
176       has  all  of  the behavior of a simple button: it can display itself in
177       either of three different ways, according to the -state option; it  can
178       be made to appear raised, sunken, or flat; it can be made to flash; and
179       it invokes a Tcl command whenever mouse button 1 is  clicked  over  the
180       check button.
181
182       In  addition,  radiobuttons  can  be  selected.   If  a  radiobutton is
183       selected, the indicator is normally drawn with a  selected  appearance,
184       and a Tcl variable associated with the radiobutton is set to a particu‐
185       lar value (normally 1).  Under Unix, the  indicator  is  drawn  with  a
186       sunken  relief  and  a  special color.  Under Windows, the indicator is
187       drawn with a round mark inside.  If the radiobutton  is  not  selected,
188       then the indicator is drawn with a deselected appearance, and the asso‐
189       ciated variable is set to a different value (typically 0).  The indica‐
190       tor is drawn without a round mark inside.  Typically, several radiobut‐
191       tons share a single variable and the value of  the  variable  indicates
192       which radiobutton is to be selected.  When a radiobutton is selected it
193       sets the value of the variable to indicate that fact;  each radiobutton
194       also  monitors  the value of the variable and automatically selects and
195       deselects itself when the variable's value changes.  If the  variable's
196       value  matches  the -tristatevalue, then the radiobutton is drawn using
197       the tri-state mode.  This mode is used to indicate  mixed  or  multiple
198       values.   (This  is  used  when the radiobutton represents the state of
199       multiple items.)  By default the variable selectedButton is used;   its
200       contents  give  the  name  of the button that is selected, or the empty
201       string if no button associated with that  variable  is  selected.   The
202       name  of the variable for a radiobutton, plus the variable to be stored
203       into it, may be modified with options on the command  line  or  in  the
204       option  database.  Configuration options may also be used to modify the
205       way the indicator is displayed (or whether it is displayed at all).  By
206       default a radiobutton is configured to select itself on button clicks.
207

WIDGET COMMAND

209       The  radiobutton  command creates a new Tcl command whose name is path‐
210       Name.  This command may be used to invoke  various  operations  on  the
211       widget.  It has the following general form:
212              pathName option ?arg arg ...?
213       Option  and  the args determine the exact behavior of the command.  The
214       following commands are possible for radiobutton widgets:
215
216       pathName cget option
217              Returns the current value of the configuration option  given  by
218              option.   Option  may  have  any  of  the values accepted by the
219              radiobutton command.
220
221       pathName configure ?option? ?value option value ...?
222              Query or modify the configuration options of the widget.  If  no
223              option is specified, returns a list describing all of the avail‐
224              able options for pathName (see Tk_ConfigureInfo for  information
225              on  the  format  of  this list).  If option is specified with no
226              value, the command returns  a  list  describing  the  one  named
227              option (this list will be identical to the corresponding sublist
228              of the value returned if no option is  specified).   If  one  or
229              more  option-value pairs are specified, the command modifies the
230              given widget option(s) to have the given value(s);  in this case
231              the command returns an empty string.  Option may have any of the
232              values accepted by the radiobutton command.
233
234       pathName deselect
235              Deselects the radiobutton and sets the associated variable to an
236              empty  string.   If this radiobutton was not currently selected,
237              the command has no effect.
238
239       pathName flash
240              Flashes the radiobutton.  This is accomplished  by  redisplaying
241              the  radiobutton  several  times, alternating between active and
242              normal colors.  At the end of the flash the radiobutton is  left
243              in the same normal/active state as when the command was invoked.
244              This command is ignored if the radiobutton's state is disabled.
245
246       pathName invoke
247              Does just what would have  happened  if  the  user  invoked  the
248              radiobutton  with  the mouse: selects the button and invokes its
249              associated Tcl command, if there is one.  The  return  value  is
250              the  return  value  from  the Tcl command, or an empty string if
251              there is no command associated with the radiobutton.  This  com‐
252              mand is ignored if the radiobutton's state is disabled.
253
254       pathName select
255              Selects  the radiobutton and sets the associated variable to the
256              value corresponding to this widget.
257

BINDINGS

259       Tk automatically creates class bindings for radiobuttons that give them
260       the following default behavior:
261
262       [1]    On  Unix  systems,  a  radiobutton  activates whenever the mouse
263              passes over it and deactivates whenever  the  mouse  leaves  the
264              radiobutton.  On Mac and Windows systems, when mouse button 1 is
265              pressed over a radiobutton, the button  activates  whenever  the
266              mouse pointer is inside the button, and deactivates whenever the
267              mouse pointer leaves the button.
268
269       [2]    When mouse button 1 is pressed over a radiobutton it is  invoked
270              (it  becomes selected and the command associated with the button
271              is invoked, if there is one).
272
273       [3]    When a radiobutton has the input focus, the space key causes the
274              radiobutton to be invoked.
275
276       If  the  radiobutton's state is disabled then none of the above actions
277       occur:  the radiobutton is completely non-responsive.
278
279       The behavior of radiobuttons can be changed by  defining  new  bindings
280       for individual widgets or by redefining the class bindings.
281

SEE ALSO

283       checkbutton(n),   labelframe(n),   listbox(n),   options(n),  scale(n),
284       ttk::radiobutton(n)
285

KEYWORDS

287       radiobutton, widget
288
289
290
291Tk                                    4.4                       radiobutton(n)
Impressum