Debian Codegraph @

info/gcl-tk/radiobutton.html

raw
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6 <title>radiobutton (GCL TK Manual)</title>
7
8 <meta name="description" content="radiobutton (GCL TK Manual)">
9 <meta name="keywords" content="radiobutton (GCL TK Manual)">
10 <meta name="resource-type" content="document">
11 <meta name="distribution" content="global">
12 <meta name="Generator" content="makeinfo">
13 <link href="index.html" rel="start" title="Top">
14 <link href="wm.html#SEC_Contents" rel="contents" title="Table of Contents">
15 <link href="Widgets.html" rel="up" title="Widgets">
16 <link href="toplevel.html" rel="next" title="toplevel">
17 <link href="label.html" rel="prev" title="label">
18 <style type="text/css">
19 <!--
20 a.summary-letter {text-decoration: none}
21 blockquote.indentedblock {margin-right: 0em}
22 div.display {margin-left: 3.2em}
23 div.example {margin-left: 3.2em}
24 div.lisp {margin-left: 3.2em}
25 kbd {font-style: oblique}
26 pre.display {font-family: inherit}
27 pre.format {font-family: inherit}
28 pre.menu-comment {font-family: serif}
29 pre.menu-preformatted {font-family: serif}
30 span.nolinebreak {white-space: nowrap}
31 span.roman {font-family: initial; font-weight: normal}
32 span.sansserif {font-family: sans-serif; font-weight: normal}
33 ul.no-bullet {list-style: none}
34 -->
35 </style>
36
37
38 </head>
39
40 <body lang="en">
41 <span id="radiobutton"></span><div class="header">
42 <p>
43 Next: <a href="toplevel.html" accesskey="n" rel="next">toplevel</a>, Previous: <a href="label.html" accesskey="p" rel="prev">label</a>, Up: <a href="Widgets.html" accesskey="u" rel="up">Widgets</a> &nbsp; [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
44 </div>
45 <hr>
46 <span id="radiobutton-1"></span><h3 class="section">2.14 radiobutton</h3>
47
48 <p>radiobutton \- Create and manipulate radio-button widgets
49 </p><span id="Synopsis-13"></span><h4 class="unnumberedsubsec">Synopsis</h4>
50 <p><b>radiobutton</b><i> </i><i>pathName </i><span class="roman">?</span><i>options</i>?
51 </p><span id="Standard-Options-13"></span><h4 class="unnumberedsubsec">Standard Options</h4>
52
53
54 <div class="example">
55 <pre class="example">activeBackground bitmap font relief
56 activeForeground borderWidth foreground text
57 anchor cursor padX textVariable
58 background disabledForeground padX
59 </pre></div>
60
61
62 <p>See <a href="options.html">options</a>, for more information.
63 </p><span id="Arguments-for-Radiobutton"></span><h4 class="unnumberedsubsec">Arguments for Radiobutton</h4>
64
65
66 <dl compact="compact">
67 <dt><code><b>:command</b></code></dt>
68 <dd><p align="right">Name=<code>&quot;<b>command</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Command</b>&quot;</code>
69 </p><br>
70
71 <p>Specifies a Tcl command to associate with the button. This command
72 is typically invoked when mouse button 1 is released over the button
73 window. The button&rsquo;s global variable (<b>:variable</b> option) will
74 be updated before the command is invoked.
75 </p></dd>
76 </dl>
77
78
79 <dl compact="compact">
80 <dt><code><b>:height</b></code></dt>
81 <dd><p align="right">Name=<code>&quot;<b>height</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Height</b>&quot;</code>
82 </p><br>
83
84 <p>Specifies a desired height for the button.
85 If a bitmap is being displayed in the button then the value is in
86 screen units (i.e. any of the forms acceptable to <b>Tk_GetPixels</b>);
87 for text it is in lines of text.
88 If this option isn&rsquo;t specified, the button&rsquo;s desired height is computed
89 from the size of the bitmap or text being displayed in it.
90 </p></dd>
91 </dl>
92
93
94 <dl compact="compact">
95 <dt><code><b>:selector</b></code></dt>
96 <dd><p align="right">Name=<code>&quot;<b>selector</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Foreground</b>&quot;</code>
97 </p><br>
98
99 <p>Specifies the color to draw in the selector when this button is
100 selected.
101 If specified as an empty string then no selector is drawn for the button.
102 </p></dd>
103 </dl>
104
105
106 <dl compact="compact">
107 <dt><code><b>:state</b></code></dt>
108 <dd><p align="right">Name=<code>&quot;<b>state</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>State</b>&quot;</code>
109 </p><br>
110
111 <p>Specifies one of three states for the radio button: <b>normal</b><span class="roman">, </span><b>active</b>,
112 or <b>disabled</b>. In normal state the radio button is displayed using the
113 <b>foreground</b><span class="roman"> and </span><b>background</b> options. The active state is
114 typically used when the pointer is over the radio button. In active state
115 the radio button is displayed using the <b>activeForeground</b> and
116 <b>activeBackground</b> options. Disabled state means that the radio button
117 is insensitive: it doesn&rsquo;t activate and doesn&rsquo;t respond to mouse
118 button presses. In this state the <b>disabledForeground</b> and
119 <b>background</b> options determine how the radio button is displayed.
120 </p></dd>
121 </dl>
122
123
124 <dl compact="compact">
125 <dt><code><b>:value</b></code></dt>
126 <dd><p align="right">Name=<code>&quot;<b>value</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Value</b>&quot;</code>
127 </p><br>
128
129 <p>Specifies value to store in the button&rsquo;s associated variable whenever
130 this button is selected. Defaults to the name of the radio button.
131 </p></dd>
132 </dl>
133
134
135 <dl compact="compact">
136 <dt><code><b>:variable</b></code></dt>
137 <dd><p align="right">Name=<code>&quot;<b>variable</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Variable</b>&quot;</code>
138 </p><br>
139
140 <p>Specifies name of global variable to set whenever this button is
141 selected. Changes in this variable also cause the button to select
142 or deselect itself.
143 Defaults to the value <b>selectedButton</b>.
144 </p></dd>
145 </dl>
146
147
148 <dl compact="compact">
149 <dt><code><b>:width</b></code></dt>
150 <dd><p align="right">Name=<code>&quot;<b>width</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Width</b>&quot;</code>
151 </p><br>
152
153 <p>Specifies a desired width for the button.
154 If a bitmap is being displayed in the button then the value is in
155 screen units (i.e. any of the forms acceptable to <b>Tk_GetPixels</b>);
156 for text it is in characters.
157 If this option isn&rsquo;t specified, the button&rsquo;s desired width is computed
158 from the size of the bitmap or text being displayed in it.
159 </p></dd>
160 </dl>
161
162 <span id="Description-10"></span><h4 class="unnumberedsubsec">Description</h4>
163
164 <p>The <b>radiobutton</b> command creates a new window (given by the
165 <i>pathName</i> argument) and makes it into a radiobutton widget.
166 Additional
167 options, described above, may be specified on the command line
168 or in the option database
169 to configure aspects of the radio button such as its colors, font,
170 text, and initial relief. The <b>radiobutton</b> command returns its
171 <i>pathName</i> argument. At the time this command is invoked,
172 there must not exist a window named <i>pathName</i>, but
173 <i>pathName</i>&rsquo;s parent must exist.
174 </p>
175 <p>A radio button is a widget
176 that displays a textual string or bitmap
177 and a diamond called a <i>selector</i>.
178 A radio button has
179 all of the behavior of a simple button: it can display itself in either
180 of three different ways, according to the <b>state</b> option;
181 it can be made to appear
182 raised, sunken, or flat; it can be made to flash; and it invokes
183 a Tcl command whenever mouse button 1 is clicked over the
184 check button.
185 </p>
186 <p>In addition, radio buttons can be <i>selected</i>.
187 If a radio button is selected then a special highlight appears
188 in the selector and a Tcl variable associated with the radio button
189 is set to a particular value.
190 If the radio button is not selected then the selector is drawn
191 in a different fashion.
192 Typically, several radio buttons share a single variable and the
193 value of the variable indicates which radio button is to be selected.
194 When a radio button is selected it sets the value of the variable to
195 indicate that fact; each radio button also monitors the value of
196 the variable and automatically selects and deselects itself when the
197 variable&rsquo;s value changes.
198 By default the variable <b>selectedButton</b>
199 is used; its contents give the name of the button that is
200 selected, or the empty string if no button associated with that
201 variable is selected.
202 The name of the variable for a radio button,
203 plus the variable to be stored into it, may be modified with options
204 on the command line or in the option database. By default a radio
205 button is configured to select itself on button clicks.
206 </p>
207 <span id="A-Radiobutton-Widget_0027s-Arguments"></span><h4 class="unnumberedsubsec">A Radiobutton Widget&rsquo;s Arguments</h4>
208
209 <p>The <b>radiobutton</b> command creates a new Tcl command whose
210 name is <i>pathName</i>. This
211 command may be used to invoke various
212 operations on the widget. It has the following general form:
213 </p>
214 <div class="example">
215 <pre class="example"><i>pathName option </i><span class="roman">?</span><i>arg arg ...</i>?
216 </pre></div>
217
218 <p><i>Option</i><span class="roman"> and the </span><i>arg</i>s
219 determine the exact behavior of the command. The following
220 commands are possible for radio-button widgets:
221 </p>
222 <dl compact="compact">
223 <dt><i>pathName </i><b>:activate</b></dt>
224 <dd><p>Change the radio button&rsquo;s state to <b>active</b> and redisplay the button
225 using its active foreground and background colors instead of normal
226 colors.
227 This command is ignored if the radio button&rsquo;s state is <b>disabled</b>.
228 This command is obsolete and will eventually be removed;
229 use &ldquo;<i>pathName </i><b>:configure :state active</b>&rdquo; instead.
230 </p></dd>
231 <dt><i>pathName </i><b>:configure</b><span class="roman"> ?</span><i>option</i><span class="roman">? ?</span><i>value option value ...</i>?</dt>
232 <dd><p>Query or modify the configuration options of the widget.
233 If no <i>option</i> is specified, returns a list describing all of
234 the available options for <i>pathName</i><span class="roman"> (see </span><b>Tk_ConfigureInfo</b> for
235 information on the format of this list). If <i>option</i> is specified
236 with no <i>value</i>, then the command returns a list describing the
237 one named option (this list will be identical to the corresponding
238 sublist of the value returned if no <i>option</i> is specified). If
239 one or more <i>option:value</i> pairs are specified, then the command
240 modifies the given widget option(s) to have the given value(s); in
241 this case the command returns an empty string.
242 <i>Option</i><span class="roman"> may have any of the values accepted by the </span><b>radiobutton</b>
243 command.
244 </p></dd>
245 <dt><i>pathName </i><b>:deactivate</b></dt>
246 <dd><p>Change the radio button&rsquo;s state to <b>normal</b> and redisplay the button
247 using its normal foreground and background colors.
248 This command is ignored if the radio button&rsquo;s state is <b>disabled</b>.
249 This command is obsolete and will eventually be removed;
250 use &ldquo;<i>pathName </i><b>:configure :state normal</b>&rdquo; instead.
251 </p></dd>
252 <dt><i>pathName </i><b>:deselect</b></dt>
253 <dd><p>Deselect the radio button: redisplay it without a highlight in
254 the selector and set the associated variable to an empty string. If
255 this radio button was not currently selected, then the command has
256 no effect.
257 </p></dd>
258 <dt><i>pathName </i><b>:flash</b></dt>
259 <dd><p>Flash the radio button. This is accomplished by redisplaying the radio button
260 several times, alternating between active and normal colors. At
261 the end of the flash the radio button is left in the same normal/active
262 state as when the command was invoked.
263 This command is ignored if the radio button&rsquo;s state is <b>disabled</b>.
264 </p></dd>
265 <dt><i>pathName </i><b>:invoke</b></dt>
266 <dd><p>Does just what would have happened if the user invoked the radio button
267 with the mouse: select the button and invoke
268 its associated Tcl command, if there is one.
269 The return value is the return value from the Tcl command, or an
270 empty string if there is no command associated with the radio button.
271 This command is ignored if the radio button&rsquo;s state is <b>disabled</b>.
272 </p></dd>
273 <dt><i>pathName </i><b>:select</b></dt>
274 <dd><p>Select the radio button: display it with a highlighted
275 selector and set the associated variable to the value corresponding
276 to this widget.
277 </p>
278 </dd>
279 </dl>
280 <span id="Bindings-7"></span><h4 class="unnumberedsubsec">Bindings</h4>
281
282 <p>Tk automatically creates class bindings for radio buttons that give them
283 the following default behavior:
284 </p><ul class="no-bullet">
285 <li> [1]
286 The radio button activates whenever the mouse passes over it and deactivates
287 whenever the mouse leaves the radio button.
288 </li><li> [2]
289 The radio button&rsquo;s relief is changed to sunken whenever mouse button 1 is
290 pressed over it, and the relief is restored to its original
291 value when button 1 is later released.
292 </li><li> [3]
293 If mouse button 1 is pressed over the radio button and later released over
294 the radio button, the radio button is invoked (i.e. it is selected
295 and the command associated with the button is invoked,
296 if there is one). However, if the mouse is not
297 over the radio button when button 1 is released, then no invocation occurs.
298 </li></ul>
299
300 <p>The behavior of radio buttons can be changed by defining new bindings for
301 individual widgets or by redefining the class bindings.
302 </p>
303 <span id="Keywords-13"></span><h4 class="unnumberedsubsec">Keywords</h4>
304 <p>radio button, widget
305 </p><hr>
306 <div class="header">
307 <p>
308 Next: <a href="toplevel.html" accesskey="n" rel="next">toplevel</a>, Previous: <a href="label.html" accesskey="p" rel="prev">label</a>, Up: <a href="Widgets.html" accesskey="u" rel="up">Widgets</a> &nbsp; [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
309 </div>
310
311
312
313 </body>
314 </html>