1Radiobutton(3) User Contributed Perl Documentation Radiobutton(3)
2
3
4
6 Tk::Radiobutton - Create and manipulate Radiobutton widgets
7
9 $radiobutton = $parent->Radiobutton(?options?);
10
12 -activebackground -activeforeground -anchor -background -bitmap
13 -borderwidth -compound -cursor -disabledforeground -font -foreground
14 -highlightbackground -highlightcolor -highlightthickness -image
15 -justify -padx -pady -relief -takefocus -text -textvariable -underline
16 -wraplength
17
18 See Tk::options for details of the standard options.
19
21 Name: command
22 Class: Command
23 Switch: -command
24 Specifies a perl/Tk callback to associate with the button. This
25 command is typically invoked when mouse button 1 is released over
26 the button window. The button's global variable (-variable option)
27 will be updated before the command is invoked.
28
29 Name: height
30 Class: Height
31 Switch: -height
32 Specifies a desired height for the button. If an image or bitmap
33 is being displayed in the button then the value is in screen units
34 (i.e. any of the forms acceptable to Tk_GetPixels); for text it is
35 in lines of text. If this option isn't specified, the button's
36 desired height is computed from the size of the image or bitmap or
37 text being displayed in it.
38
39 Name: indicatorOn
40 Class: IndicatorOn
41 Switch: -indicatoron
42 Specifies whether or not the indicator should be drawn. Must be a
43 proper boolean value. If false, the relief option is ignored and
44 the widget's relief is always sunken if the widget is selected and
45 raised otherwise.
46
47 Command-Line Name: -offrelief
48 Database Name: offRelief
49 Database Class: OffRelief
50 Specifies the relief for the checkbutton when the indicator is not
51 drawn and the checkbutton is off. The default value is raised. By
52 setting this option to flat and setting -indicatoron false
53 -overrelief raised, the effect is achieved of having a flat button
54 that raises on mouse-over and which is depressed when activated.
55 This is the behavior typically exhibited by the Bold, Italic, and
56 Underline checkbuttons on the toolbar of a word-processor, for
57 example.
58
59 Command-Line Name: -overrelief
60 Database Name: overRelief
61 Database Class: OverRelief
62 Specifies an alternative relief for the button, to be used when
63 the mouse cursor is over the widget. This option can be used to
64 make toolbar buttons, by configuring -relief flat -overrelief
65 raised. If the value of this option is the empty string, then no
66 alternative relief is used when the mouse cursor is over the
67 button. The empty string is the default value.
68
69 Name: selectColor
70 Class: Background
71 Switch: -selectcolor
72 Specifies a background color to use when the button is selected.
73 If indicatorOn is true then the color applies to the indicator.
74 Under Windows, this color is used as the background for the
75 indicator regardless of the select state. If indicatorOn is false,
76 this color is used as the background for the entire widget, in
77 place of background or activeBackground, whenever the widget is
78 selected. If specified as an empty string then no special color is
79 used for displaying when the widget is selected.
80
81 Name: selectImage
82 Class: SelectImage
83 Switch: -selectimage
84 Specifies an image to display (in place of the image option) when
85 the radiobutton is selected. This option is ignored unless the
86 image option has been specified.
87
88 Name: state
89 Class: State
90 Switch: -state
91 Specifies one of three states for the radiobutton: normal, active,
92 or disabled. In normal state the radiobutton is displayed using
93 the foreground and background options. The active state is
94 typically used when the pointer is over the radiobutton. In active
95 state the radiobutton is displayed using the activeForeground and
96 activeBackground options. Disabled state means that the
97 radiobutton should be insensitive: the default bindings will
98 refuse to activate the widget and will ignore mouse button presses.
99 In this state the disabledForeground and background options
100 determine how the radiobutton is displayed.
101
102 Name: value
103 Class: Value
104 Switch: -value
105 Specifies value to store in the button's associated variable
106 whenever this button is selected.
107
108 Name: variable
109 Class: Variable
110 Switch: -variable
111 Specifies reference to a variable to set whenever this button is
112 selected. Changes in this variable also cause the button to select
113 or deselect itself. Defaults to the value "\$Tk::selectedButton".
114
115 Name: width
116 Class: Width
117 Switch: -width
118 Specifies a desired width for the button. If an image or bitmap is
119 being displayed in the button, the value is in screen units (i.e.
120 any of the forms acceptable to Tk_GetPixels); for text it is in
121 characters. If this option isn't specified, the button's desired
122 width is computed from the size of the image or bitmap or text
123 being displayed in it.
124
126 The Radiobutton method creates a new window (given by the $widget
127 argument) and makes it into a radiobutton widget. Additional options,
128 described above, may be specified on the command line or in the option
129 database to configure aspects of the radiobutton such as its colors,
130 font, text, and initial relief. The radiobutton command returns its
131 $widget argument. At the time this command is invoked, there must not
132 exist a window named $widget, but $widget's parent must exist.
133
134 A radiobutton is a widget that displays a textual string, bitmap or
135 image and a diamond or circle called an indicator. If text is
136 displayed, it must all be in a single font, but it can occupy multiple
137 lines on the screen (if it contains newlines or if wrapping occurs
138 because of the wrapLength option) and one of the characters may
139 optionally be underlined using the underline option. A radiobutton has
140 all of the behavior of a simple button: it can display itself in either
141 of three different ways, according to the state option; it can be made
142 to appear raised, sunken, or flat; it can be made to flash; and it
143 invokes a perl/Tk callback whenever mouse button 1 is clicked over the
144 check button.
145
146 In addition, radiobuttons can be selected. If a radiobutton is
147 selected, the indicator is normally drawn with a selected appearance,
148 and a Tcl variable associated with the radiobutton is set to a
149 particular value (normally 1). Under Unix, the indicator is drawn with
150 a sunken relief and a special color. Under Windows, the indicator is
151 drawn with a round mark inside. If the radiobutton is not selected,
152 then the indicator is drawn with a deselected appearance, and the
153 associated variable is set to a different value (typically 0). Under
154 Unix, the indicator is drawn with a raised relief and no special color.
155 Under Windows, the indicator is drawn without a round mark inside.
156 Typically, several radiobuttons share a single variable and the value
157 of the variable indicates which radiobutton is to be selected. When a
158 radiobutton is selected it sets the value of the variable to indicate
159 that fact; each radiobutton also monitors the value of the variable
160 and automatically selects and deselects itself when the variable's
161 value changes. By default the variable selectedButton is used; its
162 contents give the name of the button that is selected, or the empty
163 string if no button associated with that variable is selected. The
164 name of the variable for a radiobutton, plus the variable to be stored
165 into it, may be modified with options on the command line or in the
166 option database. Configuration options may also be used to modify the
167 way the indicator is displayed (or whether it is displayed at all). By
168 default a radiobutton is configured to select itself on button clicks.
169
171 The Radiobutton method creates a widget object. This object supports
172 the configure and cget methods described in Tk::options which can be
173 used to enquire and modify the options described above. The widget
174 also inherits all the methods provided by the generic Tk::Widget class.
175
176 The following additional methods are available for radiobutton widgets:
177
178 $radiobutton->deselect
179 Deselects the radiobutton and sets the associated variable to an
180 empty string. If this radiobutton was not currently selected, the
181 command has no effect.
182
183 $radiobutton->flash
184 Flashes the radiobutton. This is accomplished by redisplaying the
185 radiobutton several times, alternating between active and normal
186 colors. At the end of the flash the radiobutton is left in the
187 same normal/active state as when the command was invoked. This
188 command is ignored if the radiobutton's state is disabled.
189
190 $radiobutton->invoke
191 Does just what would have happened if the user invoked the
192 radiobutton with the mouse: selects the button and invokes its
193 associated Tcl command, if there is one. The return value is the
194 return value from the Tcl command, or an empty string if there is
195 no command associated with the radiobutton. This command is
196 ignored if the radiobutton's state is disabled.
197
198 $radiobutton->select
199 Selects the radiobutton and sets the associated variable to the
200 value corresponding to this widget.
201
203 Tk automatically creates class bindings for radiobuttons that give them
204 the following default behavior:
205
206 [1] On Unix systems, a radiobutton activates whenever the mouse passes
207 over it and deactivates whenever the mouse leaves the radiobutton.
208 On Mac and Windows systems, when mouse button 1 is pressed over a
209 radiobutton, the button activates whenever the mouse pointer is
210 inside the button, and deactivates whenever the mouse pointer
211 leaves the button.
212
213 [2] When mouse button 1 is pressed over a radiobutton it is invoked (it
214 becomes selected and the command associated with the button is
215 invoked, if there is one).
216
217 [3] When a radiobutton has the input focus, the space key causes the
218 radiobutton to be invoked.
219
220 If the radiobutton's state is disabled then none of the above
221 actions occur: the radiobutton is completely non-responsive.
222
223 The behavior of radiobuttons can be changed by defining new
224 bindings for individual widgets or by redefining the class
225 bindings.
226
228 radiobutton, widget
229
230
231
232perl v5.28.0 2018-07-15 Radiobutton(3)