1radiobutton(n) Tk Built-In Commands radiobutton(n)
2
3
4
5______________________________________________________________________________
6
8 radiobutton - Create and manipulate radiobutton widgets
9
11 radiobutton pathName ?options?
12
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
26 [-command command] Specifies a Tcl command to associate with the but‐
27 ton. This command is typically invoked when mouse button 1 is released
28 over the button window. The button's global variable (-variable
29 option) will be updated before the command is invoked.
30 [-height height] Specifies a desired height for the button. If an
31 image or bitmap is being displayed in the button then the value is in
32 screen units (i.e. any of the forms acceptable to Tk_GetPixels); for
33 text it is in lines of text. If this option is not specified, the but‐
34 ton's desired height is computed from the size of the image or bitmap
35 or text being displayed in it. [-indicatoron indicatorOn] Specifies
36 whether or not the indicator should be drawn. Must be a proper boolean
37 value. If false, the relief option is ignored and the widget's relief
38 is always sunken if the widget is selected and raised otherwise.
39 [-selectcolor selectColor] Specifies a background color to use when the
40 button is selected. If indicatorOn is true then the color applies to
41 the indicator. Under Windows, this color is used as the background for
42 the indicator regardless of the select state. If indicatorOn is false,
43 this color is used as the background for the entire widget, in place of
44 background or activeBackground, whenever the widget is selected. If
45 specified as an empty string then no special color is used for display‐
46 ing when the widget is selected. [-offrelief offRelief] Specifies the
47 relief for the checkbutton when the indicator is not drawn and the
48 checkbutton is off. The default value is “raised”. By setting this
49 option to “flat” and setting -indicatoron to false and -overrelief to
50 “raised”, the effect is achieved of having a flat button that raises on
51 mouse-over and which is depressed when activated. This is the behavior
52 typically exhibited by the Align-Left, Align-Right, and Center
53 radiobuttons on the toolbar of a word-processor, for example. [-over‐
54 relief overRelief] Specifies an alternative relief for the radiobutton,
55 to be used when the mouse cursor is over the widget. This option can
56 be used to make toolbar buttons, by configuring -relief flat -overre‐
57 lief raised. If the value of this option is the empty string, then no
58 alternative relief is used when the mouse cursor is over the radiobut‐
59 ton. The empty string is the default value. [-selectimage selectIm‐
60 age] Specifies an image to display (in place of the image option) when
61 the radiobutton is selected. This option is ignored unless the image
62 option has been specified. [-state state] Specifies one of three
63 states for the radiobutton: normal, active, or disabled. In normal
64 state the radiobutton is displayed using the foreground and background
65 options. The active state is typically used when the pointer is over
66 the radiobutton. In active state the radiobutton is displayed using
67 the activeForeground and activeBackground options. Disabled state
68 means that the radiobutton should be insensitive: the default bindings
69 will refuse to activate the widget and will ignore mouse button
70 presses. In this state the disabledForeground and background options
71 determine how the radiobutton is displayed. [-tristateimage tris‐
72 tateImage] Specifies an image to display (in place of the image option) │
73 when the radiobutton is selected. This option is ignored unless the │
74 image option has been specified. [-tristatevalue tristateValue] Speci‐ │
75 fies the value that causes the radiobutton to display the multi-value │
76 selection, also known as the tri-state mode. Defaults to “”.
77 [-value value] Specifies value to store in the button's associated
78 variable whenever this button is selected. [-variable variable] Speci‐
79 fies the name of a global variable to set whenever this button is
80 selected. Changes in this variable also cause the button to select or
81 deselect itself. Defaults to the value selectedButton. [-width width]
82 Specifies a desired width for the button. If an image or bitmap is
83 being displayed in the button, the value is in screen units (i.e. any
84 of the forms acceptable to Tk_GetPixels); for text it is in characters.
85 If this option is not specified, the button's desired width is computed
86 from the size of the image or bitmap or text being displayed in it.
87_________________________________________________________________
88
90 The radiobutton command creates a new window (given by the pathName
91 argument) and makes it into a radiobutton widget. Additional options,
92 described above, may be specified on the command line or in the option
93 database to configure aspects of the radiobutton such as its colors,
94 font, text, and initial relief. The radiobutton command returns its
95 pathName argument. At the time this command is invoked, there must not
96 exist a window named pathName, but pathName's parent must exist.
97
98 A radiobutton is a widget that displays a textual string, bitmap or
99 image and a diamond or circle called an indicator. If text is dis‐
100 played, it must all be in a single font, but it can occupy multiple
101 lines on the screen (if it contains newlines or if wrapping occurs
102 because of the wrapLength option) and one of the characters may option‐
103 ally be underlined using the underline option. A radiobutton has all
104 of the behavior of a simple button: it can display itself in either of
105 three different ways, according to the state option; it can be made to
106 appear raised, sunken, or flat; it can be made to flash; and it invokes
107 a Tcl command whenever mouse button 1 is clicked over the check button.
108
109 In addition, radiobuttons can be selected. If a radiobutton is
110 selected, the indicator is normally drawn with a selected appearance,
111 and a Tcl variable associated with the radiobutton is set to a particu‐
112 lar value (normally 1). Under Unix, the indicator is drawn with a
113 sunken relief and a special color. Under Windows, the indicator is
114 drawn with a round mark inside. If the radiobutton is not selected,
115 then the indicator is drawn with a deselected appearance, and the asso‐
116 ciated variable is set to a different value (typically 0). The indica‐
117 tor is drawn without a round mark inside. Typically, several radiobut‐
118 tons share a single variable and the value of the variable indicates
119 which radiobutton is to be selected. When a radiobutton is selected it
120 sets the value of the variable to indicate that fact; each radiobutton
121 also monitors the value of the variable and automatically selects and
122 deselects itself when the variable's value changes. If the variable's │
123 value matches the tristateValue, then the radiobutton is drawn using │
124 the tri-state mode. This mode is used to indicate mixed or multiple │
125 values. (This is used when the radiobutton represents the state of │
126 multiple items.) By default the variable selectedButton is used; its
127 contents give the name of the button that is selected, or the empty
128 string if no button associated with that variable is selected. The
129 name of the variable for a radiobutton, plus the variable to be stored
130 into it, may be modified with options on the command line or in the
131 option database. Configuration options may also be used to modify the
132 way the indicator is displayed (or whether it is displayed at all). By
133 default a radiobutton is configured to select itself on button clicks.
134
136 The radiobutton command creates a new Tcl command whose name is path‐
137 Name. This command may be used to invoke various operations on the
138 widget. It has the following general form:
139 pathName option ?arg arg ...?
140 Option and the args determine the exact behavior of the command. The
141 following commands are possible for radiobutton widgets:
142
143 pathName cget option
144 Returns the current value of the configuration option given by
145 option. Option may have any of the values accepted by the
146 radiobutton command.
147
148 pathName configure ?option? ?value option value ...?
149 Query or modify the configuration options of the widget. If no
150 option is specified, returns a list describing all of the avail‐
151 able options for pathName (see Tk_ConfigureInfo for information
152 on the format of this list). If option is specified with no
153 value, the command returns a list describing the one named
154 option (this list will be identical to the corresponding sublist
155 of the value returned if no option is specified). If one or
156 more option-value pairs are specified, the command modifies the
157 given widget option(s) to have the given value(s); in this case
158 the command returns an empty string. Option may have any of the
159 values accepted by the radiobutton command.
160
161 pathName deselect
162 Deselects the radiobutton and sets the associated variable to an
163 empty string. If this radiobutton was not currently selected,
164 the command has no effect.
165
166 pathName flash
167 Flashes the radiobutton. This is accomplished by redisplaying
168 the radiobutton several times, alternating between active and
169 normal colors. At the end of the flash the radiobutton is left
170 in the same normal/active state as when the command was invoked.
171 This command is ignored if the radiobutton's state is disabled.
172
173 pathName invoke
174 Does just what would have happened if the user invoked the
175 radiobutton with the mouse: selects the button and invokes its
176 associated Tcl command, if there is one. The return value is
177 the return value from the Tcl command, or an empty string if
178 there is no command associated with the radiobutton. This com‐
179 mand is ignored if the radiobutton's state is disabled.
180
181 pathName select
182 Selects the radiobutton and sets the associated variable to the
183 value corresponding to this widget.
184
186 Tk automatically creates class bindings for radiobuttons that give them
187 the following default behavior:
188
189 [1] On Unix systems, a radiobutton activates whenever the mouse
190 passes over it and deactivates whenever the mouse leaves the
191 radiobutton. On Mac and Windows systems, when mouse button 1 is
192 pressed over a radiobutton, the button activates whenever the
193 mouse pointer is inside the button, and deactivates whenever the
194 mouse pointer leaves the button.
195
196 [2] When mouse button 1 is pressed over a radiobutton it is invoked
197 (it becomes selected and the command associated with the button
198 is invoked, if there is one).
199
200 [3] When a radiobutton has the input focus, the space key causes the
201 radiobutton to be invoked.
202
203 If the radiobutton's state is disabled then none of the above actions
204 occur: the radiobutton is completely non-responsive.
205
206 The behavior of radiobuttons can be changed by defining new bindings
207 for individual widgets or by redefining the class bindings.
208
210 checkbutton(n), labelframe(n), listbox(n), options(n), scale(n),
211 ttk::radiobutton(n)
212
214 radiobutton, widget
215
216
217
218Tk 4.4 radiobutton(n)