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 isn't 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. [-value value] Specifies
72 value to store in the button's associated variable whenever this button
73 is selected. [-variable variable] Specifies name of global variable to
74 set whenever this button is selected. Changes in this variable also
75 cause the button to select or deselect itself. Defaults to the value
76 selectedButton. [-width width] Specifies a desired width for the but‐
77 ton. If an image or bitmap is being displayed in the button, the value
78 is in screen units (i.e. any of the forms acceptable to Tk_GetPixels);
79 for text it is in characters. If this option isn't specified, the but‐
80 ton's desired width is computed from the size of the image or bitmap or
81 text being displayed in it.
82_________________________________________________________________
83
84
86 The radiobutton command creates a new window (given by the pathName
87 argument) and makes it into a radiobutton widget. Additional options,
88 described above, may be specified on the command line or in the option
89 database to configure aspects of the radiobutton such as its colors,
90 font, text, and initial relief. The radiobutton command returns its
91 pathName argument. At the time this command is invoked, there must not
92 exist a window named pathName, but pathName's parent must exist.
93
94 A radiobutton is a widget that displays a textual string, bitmap or │
95 image and a diamond or circle called an indicator. If text is dis‐
96 played, it must all be in a single font, but it can occupy multiple
97 lines on the screen (if it contains newlines or if wrapping occurs
98 because of the wrapLength option) and one of the characters may option‐
99 ally be underlined using the underline option. A radiobutton has all
100 of the behavior of a simple button: it can display itself in either of
101 three different ways, according to the state option; it can be made to
102 appear raised, sunken, or flat; it can be made to flash; and it invokes
103 a Tcl command whenever mouse button 1 is clicked over the check button.
104
105 In addition, radiobuttons can be selected. If a radiobutton is
106 selected, the indicator is normally drawn with a selected appearance, │
107 and a Tcl variable associated with the radiobutton is set to a particu‐ │
108 lar value (normally 1). Under Unix, the indicator is drawn with a │
109 sunken relief and a special color. Under Windows, the indicator is │
110 drawn with a round mark inside. If the radiobutton is not selected, │
111 then the indicator is drawn with a deselected appearance, and the asso‐ │
112 ciated variable is set to a different value (typically 0). Under Unix, │
113 the indicator is drawn with a raised relief and no special color. │
114 Under Windows, the indicator is drawn without a round mark inside.
115 Typically, several radiobuttons share a single variable and the value
116 of the variable indicates which radiobutton is to be selected. When a
117 radiobutton is selected it sets the value of the variable to indicate
118 that fact; each radiobutton also monitors the value of the variable
119 and automatically selects and deselects itself when the variable's
120 value changes. By default the variable selectedButton is used; its
121 contents give the name of the button that is selected, or the empty
122 string if no button associated with that variable is selected. The
123 name of the variable for a radiobutton, plus the variable to be stored
124 into it, may be modified with options on the command line or in the
125 option database. Configuration options may also be used to modify the
126 way the indicator is displayed (or whether it is displayed at all). By
127 default a radiobutton is configured to select itself on button clicks.
128
130 The radiobutton command creates a new Tcl command whose name is path‐
131 Name. This command may be used to invoke various operations on the
132 widget. It has the following general form:
133 pathName option ?arg arg ...?
134 Option and the args determine the exact behavior of the command. The
135 following commands are possible for radiobutton widgets:
136
137 pathName cget option
138 Returns the current value of the configuration option given by
139 option. Option may have any of the values accepted by the
140 radiobutton command.
141
142 pathName configure ?option? ?value option value ...?
143 Query or modify the configuration options of the widget. If no
144 option is specified, returns a list describing all of the avail‐
145 able options for pathName (see Tk_ConfigureInfo for information
146 on the format of this list). If option is specified with no
147 value, the command returns a list describing the one named
148 option (this list will be identical to the corresponding sublist
149 of the value returned if no option is specified). If one or
150 more option-value pairs are specified, the command modifies the
151 given widget option(s) to have the given value(s); in this case
152 the command returns an empty string. Option may have any of the
153 values accepted by the radiobutton command.
154
155 pathName deselect
156 Deselects the radiobutton and sets the associated variable to an
157 empty string. If this radiobutton was not currently selected,
158 the command has no effect.
159
160 pathName flash
161 Flashes the radiobutton. This is accomplished by redisplaying
162 the radiobutton several times, alternating between active and
163 normal colors. At the end of the flash the radiobutton is left
164 in the same normal/active state as when the command was invoked.
165 This command is ignored if the radiobutton's state is disabled.
166
167 pathName invoke
168 Does just what would have happened if the user invoked the
169 radiobutton with the mouse: selects the button and invokes its
170 associated Tcl command, if there is one. The return value is
171 the return value from the Tcl command, or an empty string if
172 there is no command associated with the radiobutton. This com‐
173 mand is ignored if the radiobutton's state is disabled.
174
175 pathName select
176 Selects the radiobutton and sets the associated variable to the
177 value corresponding to this widget.
178
180 Tk automatically creates class bindings for radiobuttons that give them
181 the following default behavior:
182
183 [1] On Unix systems, a radiobutton activates whenever the mouse │
184 passes over it and deactivates whenever the mouse leaves the │
185 radiobutton. On Mac and Windows systems, when mouse button 1 is │
186 pressed over a radiobutton, the button activates whenever the │
187 mouse pointer is inside the button, and deactivates whenever the │
188 mouse pointer leaves the button.
189
190 [2] When mouse button 1 is pressed over a radiobutton it is invoked
191 (it becomes selected and the command associated with the button
192 is invoked, if there is one).
193
194 [3] When a radiobutton has the input focus, the space key causes the
195 radiobutton to be invoked.
196
197 If the radiobutton's state is disabled then none of the above actions
198 occur: the radiobutton is completely non-responsive.
199
200 The behavior of radiobuttons can be changed by defining new bindings
201 for individual widgets or by redefining the class bindings.
202
203
205 checkbutton(n), labelframe(n), listbox(n), options(n), scale(n)
206
207
209 radiobutton, widget
210
211
212
213Tk 4.4 radiobutton(n)