Debian Codegraph @

info/gcl-tk/checkbutton.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>checkbutton (GCL TK Manual)</title>
7
8 <meta name="description" content="checkbutton (GCL TK Manual)">
9 <meta name="keywords" content="checkbutton (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="menubutton.html" rel="next" title="menubutton">
17 <link href="scrollbar.html" rel="prev" title="scrollbar">
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="checkbutton"></span><div class="header">
42 <p>
43 Next: <a href="menubutton.html" accesskey="n" rel="next">menubutton</a>, Previous: <a href="scrollbar.html" accesskey="p" rel="prev">scrollbar</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="checkbutton-1"></span><h3 class="section">2.7 checkbutton</h3>
47
48 <p>checkbutton \- Create and manipulate check-button widgets
49 </p><span id="Synopsis-6"></span><h4 class="unnumberedsubsec">Synopsis</h4>
50 <p><b>checkbutton</b><i> pathName </i><span class="roman">?</span><i>options</i>?
51 </p><span id="Standard-Options-6"></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 padY
59 </pre></div>
60
61
62 <p>See <a href="options.html">options</a>, for more information.
63 </p><span id="Arguments-for-Checkbutton"></span><h4 class="unnumberedsubsec">Arguments for Checkbutton</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>:offvalue</b></code></dt>
96 <dd><p align="right">Name=<code>&quot;<b>offValue</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Value</b>&quot;</code>
97 </p><br>
98
99 <p>Specifies value to store in the button&rsquo;s associated variable whenever
100 this button is deselected. Defaults to &ldquo;0&rdquo;.
101 </p></dd>
102 </dl>
103
104
105 <dl compact="compact">
106 <dt><code><b>:onvalue</b></code></dt>
107 <dd><p align="right">Name=<code>&quot;<b>onValue</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Value</b>&quot;</code>
108 </p><br>
109
110 <p>Specifies value to store in the button&rsquo;s associated variable whenever
111 this button is selected. Defaults to &ldquo;1&rdquo;.
112 </p></dd>
113 </dl>
114
115
116 <dl compact="compact">
117 <dt><code><b>:selector</b></code></dt>
118 <dd><p align="right">Name=<code>&quot;<b>selector</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Foreground</b>&quot;</code>
119 </p><br>
120
121 <p>Specifies the color to draw in the selector when this button is
122 selected.
123 If specified as an empty string then no selector is
124 drawn for the button.
125 </p></dd>
126 </dl>
127
128
129 <dl compact="compact">
130 <dt><code><b>:state</b></code></dt>
131 <dd><p align="right">Name=<code>&quot;<b>state</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>State</b>&quot;</code>
132 </p><br>
133
134 <p>Specifies one of three states for the check button: <b>normal</b><span class="roman">, </span><b>active</b>,
135 or <b>disabled</b>. In normal state the check button is displayed using the
136 <b>foreground</b><span class="roman"> and </span><b>background</b> options. The active state is
137 typically used when the pointer is over the check button. In active state
138 the check button is displayed using the <b>activeForeground</b> and
139 <b>activeBackground</b> options. Disabled state means that the check button
140 is insensitive: it doesn&rsquo;t activate and doesn&rsquo;t respond to mouse
141 button presses. In this state the <b>disabledForeground</b> and
142 <b>background</b> options determine how the check button is displayed.
143 </p></dd>
144 </dl>
145
146
147 <dl compact="compact">
148 <dt><code><b>:variable</b></code></dt>
149 <dd><p align="right">Name=<code>&quot;<b>variable</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Variable</b>&quot;</code>
150 </p><br>
151
152 <p>Specifies name of global variable to set to indicate whether
153 or not this button is selected. Defaults to the name of the
154 button within its parent (i.e. the last element of the button
155 window&rsquo;s path name).
156 </p></dd>
157 </dl>
158
159
160 <dl compact="compact">
161 <dt><code><b>:width</b></code></dt>
162 <dd><p align="right">Name=<code>&quot;<b>width</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Width</b>&quot;</code>
163 </p><br>
164
165 <p>Specifies a desired width for the button.
166 If a bitmap is being displayed in the button then the value is in
167 screen units (i.e. any of the forms acceptable to <b>Tk_GetPixels</b>);
168 for text it is in characters.
169 If this option isn&rsquo;t specified, the button&rsquo;s desired width is computed
170 from the size of the bitmap or text being displayed in it.
171 </p></dd>
172 </dl>
173
174 <span id="Description-4"></span><h4 class="unnumberedsubsec">Description</h4>
175
176 <p>The <b>checkbutton</b> command creates a new window (given by the
177 <i>pathName</i> argument) and makes it into a check-button widget.
178 Additional
179 options, described above, may be specified on the command line
180 or in the option database
181 to configure aspects of the check button such as its colors, font,
182 text, and initial relief. The <b>checkbutton</b> command returns its
183 <i>pathName</i> argument. At the time this command is invoked,
184 there must not exist a window named <i>pathName</i>, but
185 <i>pathName</i>&rsquo;s parent must exist.
186 </p>
187 <p>A check button is a widget
188 that displays a textual string or bitmap
189 and a square called a <i>selector</i>.
190 A check button has
191 all of the behavior of a simple button, including the
192 following: it can display itself in either of three different
193 ways, according to the <b>state</b> option;
194 it can be made to appear
195 raised, sunken, or flat; it can be made to flash; and it invokes
196 a Tcl command whenever mouse button 1 is clicked over the
197 check button.
198 </p>
199 <p>In addition, check buttons can be <i>selected</i>. If a check button is
200 selected then a special highlight appears in the selector, and
201 a Tcl variable associated with the check button is set to a particular
202 value (normally 1). If the check button is not selected, then
203 the selector is drawn in a different fashion and the associated
204 variable is set to a different value (typically 0). By default,
205 the name of the variable associated with a check button is the
206 same as the <i>name</i> used to create the check button. The
207 variable name, and the &ldquo;on&rdquo; and &ldquo;off&rdquo; values stored in it,
208 may be modified with options on the command line or in the option
209 database. By default a check button is configured to select and deselect
210 itself on alternate button clicks.
211 In addition, each check button monitors its associated variable and
212 automatically selects and deselects itself when the variables value
213 changes to and from the button&rsquo;s &ldquo;on&rdquo; value.
214 </p>
215 <span id="A-Checkbutton-Widget_0027s-Arguments"></span><h4 class="unnumberedsubsec">A Checkbutton Widget&rsquo;s Arguments</h4>
216
217 <p>The <b>checkbutton</b> command creates a new Tcl command whose
218 name is <i>pathName</i>. This
219 command may be used to invoke various
220 operations on the widget. It has the following general form:
221 </p>
222 <div class="example">
223 <pre class="example"><i>pathName option </i><span class="roman">?</span><i>arg arg ...</i>?
224 </pre></div>
225
226 <p><i>Option</i><span class="roman"> and the </span><i>arg</i>s
227 determine the exact behavior of the command. The following
228 commands are possible for check button widgets:
229 </p>
230 <dl compact="compact">
231 <dt><i>pathName </i><b>:activate</b></dt>
232 <dd><p>Change the check button&rsquo;s state to <b>active</b> and redisplay the button
233 using its active foreground and background colors instead of normal
234 colors.
235 This command is ignored if the check button&rsquo;s state is <b>disabled</b>.
236 This command is obsolete and will eventually be removed;
237 use &ldquo;<i>pathName </i><b>:configure :state active</b>&rdquo; instead.
238 </p></dd>
239 <dt><i>pathName </i><b>:configure</b><span class="roman"> ?</span><i>option</i><span class="roman">? ?</span><i>value option value ...</i>?</dt>
240 <dd><p>Query or modify the configuration options of the widget.
241 If no <i>option</i> is specified, returns a list describing all of
242 the available options for <i>pathName</i><span class="roman"> (see </span><b>Tk_ConfigureInfo</b> for
243 information on the format of this list). If <i>option</i> is specified
244 with no <i>value</i>, then the command returns a list describing the
245 one named option (this list will be identical to the corresponding
246 sublist of the value returned if no <i>option</i> is specified). If
247 one or more <i>option:value</i> pairs are specified, then the command
248 modifies the given widget option(s) to have the given value(s); in
249 this case the command returns an empty string.
250 <i>Option</i><span class="roman"> may have any of the values accepted by the </span><b>checkbutton</b>
251 command.
252 </p></dd>
253 <dt><i>pathName </i><b>:deactivate</b></dt>
254 <dd><p>Change the check button&rsquo;s state to <b>normal</b> and redisplay the button
255 using its normal foreground and background colors.
256 This command is ignored if the check button&rsquo;s state is <b>disabled</b>.
257 This command is obsolete and will eventually be removed;
258 use &ldquo;<i>pathName </i><b>:configure :state normal</b>&rdquo; instead.
259 </p></dd>
260 <dt><i>pathName </i><b>:deselect</b></dt>
261 <dd><p>Deselect the check button: redisplay it without a highlight in
262 the selector and set the associated variable to its &ldquo;off&rdquo;
263 value.
264 </p></dd>
265 <dt><i>pathName </i><b>:flash</b></dt>
266 <dd><p>Flash the check button. This is accomplished by redisplaying the check button
267 several times, alternating between active and normal colors. At
268 the end of the flash the check button is left in the same normal/active
269 state as when the command was invoked.
270 This command is ignored if the check button&rsquo;s state is <b>disabled</b>.
271 </p></dd>
272 <dt><i>pathName </i><b>:invoke</b></dt>
273 <dd><p>Does just what would have happened if the user invoked the check button
274 with the mouse: toggle the selection state of the button and invoke
275 the Tcl command associated with the check button, if there is one.
276 The return value is the return value from the Tcl command, or an
277 empty string if there is no command associated with the check button.
278 This command is ignored if the check button&rsquo;s state is <b>disabled</b>.
279 </p></dd>
280 <dt><i>pathName </i><b>:select</b></dt>
281 <dd><p>Select the check button: display it with a highlighted
282 selector and set the associated variable to its &ldquo;on&rdquo;
283 value.
284 </p></dd>
285 <dt><i>pathName </i><b>:toggle</b></dt>
286 <dd><p>Toggle the selection state of the button, redisplaying it and
287 modifying its associated variable to reflect the new state.
288 </p>
289 </dd>
290 </dl>
291 <span id="Bindings-3"></span><h4 class="unnumberedsubsec">Bindings</h4>
292
293 <p>Tk automatically creates class bindings for check buttons that give them
294 the following default behavior:
295 </p><ul class="no-bullet">
296 <li> [1]
297 The check button activates whenever the mouse passes over it and deactivates
298 whenever the mouse leaves the check button.
299 </li><li> [2]
300 The check button&rsquo;s relief is changed to sunken whenever mouse button 1 is
301 pressed over it, and the relief is restored to its original
302 value when button 1 is later released.
303 </li><li> [3]
304 If mouse button 1 is pressed over the check button and later released over
305 the check button, the check button is invoked (i.e. its selection
306 state toggles and the command associated with the button is invoked,
307 if there is one). However, if the mouse is not
308 over the check button when button 1 is released, then no invocation occurs.
309 </li></ul>
310
311 <p>If the check button&rsquo;s state is <b>disabled</b> then none of the above
312 actions occur: the check button is completely non-responsive.
313 </p>
314 <p>The behavior of check buttons can be changed by defining new bindings for
315 individual widgets or by redefining the class bindings.
316 </p>
317 <span id="Keywords-6"></span><h4 class="unnumberedsubsec">Keywords</h4>
318 <p>check button, widget
319 </p><hr>
320 <div class="header">
321 <p>
322 Next: <a href="menubutton.html" accesskey="n" rel="next">menubutton</a>, Previous: <a href="scrollbar.html" accesskey="p" rel="prev">scrollbar</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>
323 </div>
324
325
326
327 </body>
328 </html>