1Radiobutton(3)        User Contributed Perl Documentation       Radiobutton(3)
2
3
4

NAME

6       Tk::Radiobutton - Create and manipulate Radiobutton widgets
7

SYNOPSIS

9       $radiobutton = $parent->Radiobutton(?options?);
10

STANDARD OPTIONS

12       -activebackground -activeforeground -anchor -background -bitmap -bor‐
13       derwidth -compound -cursor -disabledforeground -font -foreground -high‐
14       lightbackground -highlightcolor -highlightthickness -image -justify
15       -padx -pady -relief -takefocus -text -textvariable -underline
16       -wraplength
17
18       See Tk::options for details of the standard options.
19

WIDGET-SPECIFIC OPTIONS

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 -overre‐
53           lief raised, the effect is achieved of having a flat button that
54           raises on mouse-over and which is depressed when activated.  This
55           is the behavior typically exhibited by the Bold, Italic, and Under‐
56           line checkbuttons on the toolbar of a word-processor, for example.
57
58       Command-Line Name: -overrelief
59       Database Name:  overRelief
60       Database Class: OverRelief
61           Specifies  an alternative relief for the button, to be used when
62           the mouse cursor is over the widget.  This option can be used to
63           make  toolbar  buttons,  by configuring -relief flat -overrelief
64           raised.  If the value of this option is the empty  string,  then no
65           alternative relief is used when the mouse cursor is over the but‐
66           ton.  The empty string is the default value.
67
68       Name:     selectColor
69       Class:    Background
70       Switch:   -selectcolor
71           Specifies a background color to use when the button is selected.
72           If indicatorOn is true then the color applies to the indicator.
73           Under Windows, this color is used as the background for the indica‐
74           tor regardless of the select state.  If indicatorOn is false, this
75           color is used as the background for the entire widget, in place of
76           background or activeBackground, whenever the widget is selected.
77           If specified as an empty string then no special color is used for
78           displaying when the widget is selected.
79
80       Name:     selectImage
81       Class:    SelectImage
82       Switch:   -selectimage
83           Specifies an image to display (in place of the image option) when
84           the radiobutton is selected.  This option is ignored unless the
85           image option has been specified.
86
87       Name:     state
88       Class:    State
89       Switch:   -state
90           Specifies one of three states for the radiobutton:  normal, active,
91           or disabled.  In normal state the radiobutton is displayed using
92           the foreground and background options.  The active state is typi‐
93           cally used when the pointer is over the radiobutton.  In active
94           state the radiobutton is displayed using the activeForeground and
95           activeBackground options.  Disabled state means that the radiobut‐
96           ton should be insensitive:  the default bindings will refuse to
97           activate the widget and will ignore mouse button presses.  In this
98           state the disabledForeground and background options determine how
99           the radiobutton is displayed.
100
101       Name:     value
102       Class:    Value
103       Switch:   -value
104           Specifies value to store in the button's associated variable when‐
105           ever this button is selected.
106
107       Name:     variable
108       Class:    Variable
109       Switch:   -variable
110           Specifies reference to a variable to set whenever this button is
111           selected.  Changes in this variable also cause the button to select
112           or deselect itself. Defaults to the value "\$Tk::selectedButton".
113
114       Name:     width
115       Class:    Width
116       Switch:   -width
117           Specifies a desired width for the button.  If an image or bitmap is
118           being displayed in the button, the value is in screen units (i.e.
119           any of the forms acceptable to Tk_GetPixels); for text it is in
120           characters.  If this option isn't specified, the button's desired
121           width is computed from the size of the image or bitmap or text
122           being displayed in it.
123

DESCRIPTION

125       The Radiobutton method creates a new window (given by the $widget argu‐
126       ment) and makes it into a radiobutton widget.  Additional options,
127       described above, may be specified on the command line or in the option
128       database to configure aspects of the radiobutton such as its colors,
129       font, text, and initial relief.  The radiobutton command returns its
130       $widget argument.  At the time this command is invoked, there must not
131       exist a window named $widget, but $widget's parent must exist.
132
133       A radiobutton is a widget that displays a textual string, bitmap or
134       image and a diamond or circle called an indicator.  If text is dis‐
135       played, it must all be in a single font, but it can occupy multiple
136       lines on the screen (if it contains newlines or if wrapping occurs
137       because of the wrapLength option) and one of the characters may option‐
138       ally be underlined using the underline option.  A radiobutton has all
139       of the behavior of a simple button: it can display itself in either of
140       three different ways, according to the state option; it can be made to
141       appear raised, sunken, or flat; it can be made to flash; and it invokes
142       a perl/Tk callback whenever mouse button 1 is clicked over the check
143       button.
144
145       In addition, radiobuttons can be selected.  If a radiobutton is
146       selected, the indicator is normally drawn with a selected appearance,
147       and a Tcl variable associated with the radiobutton is set to a particu‐
148       lar value (normally 1).  Under Unix, the indicator is drawn with a
149       sunken relief and a special color.  Under Windows, the indicator is
150       drawn with a round mark inside.  If the radiobutton is not selected,
151       then the indicator is drawn with a deselected appearance, and the asso‐
152       ciated variable is set to a different value (typically 0).  Under Unix,
153       the indicator is drawn with a raised relief and no special color.
154       Under Windows, the indicator is drawn without a round mark inside.
155       Typically, several radiobuttons share a single variable and the value
156       of the variable indicates which radiobutton is to be selected.  When a
157       radiobutton is selected it sets the value of the variable to indicate
158       that fact;  each radiobutton also monitors the value of the variable
159       and automatically selects and deselects itself when the variable's
160       value changes.  By default the variable selectedButton is used;  its
161       contents give the name of the button that is selected, or the empty
162       string if no button associated with that variable is selected.  The
163       name of the variable for a radiobutton, plus the variable to be stored
164       into it, may be modified with options on the command line or in the
165       option database.  Configuration options may also be used to modify the
166       way the indicator is displayed (or whether it is displayed at all).  By
167       default a radiobutton is configured to select itself on button clicks.
168

WIDGET METHODS

170       The Radiobutton method creates a widget object.  This object supports
171       the configure and cget methods described in Tk::options which can be
172       used to enquire and modify the options described above.  The widget
173       also inherits all the methods provided by the generic Tk::Widget class.
174
175       The following additional methods are available for radiobutton widgets:
176
177       $radiobutton->deselect
178           Deselects the radiobutton and sets the associated variable to an
179           empty string.  If this radiobutton was not currently selected, the
180           command has no effect.
181
182       $radiobutton->flash
183           Flashes the radiobutton.  This is accomplished by redisplaying the
184           radiobutton several times, alternating between active and normal
185           colors.  At the end of the flash the radiobutton is left in the
186           same normal/active state as when the command was invoked.  This
187           command is ignored if the radiobutton's state is disabled.
188
189       $radiobutton->invoke
190           Does just what would have happened if the user invoked the
191           radiobutton with the mouse: selects the button and invokes its
192           associated Tcl command, if there is one.  The return value is the
193           return value from the Tcl command, or an empty string if there is
194           no command associated with the radiobutton.  This command is
195           ignored if the radiobutton's state is disabled.
196
197       $radiobutton->select
198           Selects the radiobutton and sets the associated variable to the
199           value corresponding to this widget.
200

BINDINGS

202       Tk automatically creates class bindings for radiobuttons that give them
203       the following default behavior:
204
205       [1] On Unix systems, a radiobutton activates whenever the mouse passes
206           over it and deactivates whenever the mouse leaves the radiobutton.
207           On Mac and Windows systems, when mouse button 1 is pressed over a
208           radiobutton, the button activates whenever the mouse pointer is
209           inside the button, and deactivates whenever the mouse pointer
210           leaves the button.
211
212       [2] When mouse button 1 is pressed over a radiobutton it is invoked (it
213           becomes selected and the command associated with the button is
214           invoked, if there is one).
215
216       [3] When a radiobutton has the input focus, the space key causes the
217           radiobutton to be invoked.
218
219           If the radiobutton's state is disabled then none of the above
220           actions occur:  the radiobutton is completely non-responsive.
221
222           The behavior of radiobuttons can be changed by defining new bind‐
223           ings for individual widgets or by redefining the class bindings.
224

KEYWORDS

226       radiobutton, widget
227
228
229
230perl v5.8.8                       2008-02-05                    Radiobutton(3)
Impressum