File: checkbutton.html

package info (click to toggle)
gcl 2.6.14-21
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 60,864 kB
  • sloc: ansic: 177,407; lisp: 151,509; asm: 128,169; sh: 22,510; cpp: 11,923; tcl: 3,181; perl: 2,930; makefile: 2,360; sed: 334; yacc: 226; lex: 95; awk: 30; fortran: 24; csh: 23
file content (328 lines) | stat: -rw-r--r-- 14,447 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>checkbutton (GCL TK Manual)</title>

<meta name="description" content="checkbutton (GCL TK Manual)">
<meta name="keywords" content="checkbutton (GCL TK Manual)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<link href="index.html" rel="start" title="Top">
<link href="wm.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Widgets.html" rel="up" title="Widgets">
<link href="menubutton.html" rel="next" title="menubutton">
<link href="scrollbar.html" rel="prev" title="scrollbar">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<span id="checkbutton"></span><div class="header">
<p>
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>
</div>
<hr>
<span id="checkbutton-1"></span><h3 class="section">2.7 checkbutton</h3>

<p>checkbutton \- Create and manipulate check-button widgets
</p><span id="Synopsis-6"></span><h4 class="unnumberedsubsec">Synopsis</h4>
<p><b>checkbutton</b><i> pathName </i><span class="roman">?</span><i>options</i>?
</p><span id="Standard-Options-6"></span><h4 class="unnumberedsubsec">Standard Options</h4>


<div class="example">
<pre class="example">activeBackground  bitmap              font        relief        
activeForeground  borderWidth         foreground  text          
anchor            cursor              padX        textVariable  
background        disabledForeground  padY        
</pre></div>


<p>See <a href="options.html">options</a>, for more information.
</p><span id="Arguments-for-Checkbutton"></span><h4 class="unnumberedsubsec">Arguments for Checkbutton</h4>


<dl compact="compact">
<dt><code><b>:command</b></code></dt>
<dd><p align="right">Name=<code>&quot;<b>command</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Command</b>&quot;</code>
</p><br>

<p>Specifies a Tcl command to associate with the button.  This command
is typically invoked when mouse button 1 is released over the button
window.  The button&rsquo;s global variable (<b>:variable</b> option) will
be updated before the command is invoked.
</p></dd>
</dl>


<dl compact="compact">
<dt><code><b>:height</b></code></dt>
<dd><p align="right">Name=<code>&quot;<b>height</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Height</b>&quot;</code>
</p><br>

<p>Specifies a desired height for the button.
If a bitmap is being displayed in the button then the value is in
screen units (i.e. any of the forms acceptable to <b>Tk_GetPixels</b>);
for text it is in lines of text.
If this option isn&rsquo;t specified, the button&rsquo;s desired height is computed
from the size of the bitmap or text being displayed in it.
</p></dd>
</dl>


<dl compact="compact">
<dt><code><b>:offvalue</b></code></dt>
<dd><p align="right">Name=<code>&quot;<b>offValue</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Value</b>&quot;</code>
</p><br>

<p>Specifies value to store in the button&rsquo;s associated variable whenever
this button is deselected.  Defaults to &ldquo;0&rdquo;.
</p></dd>
</dl>


<dl compact="compact">
<dt><code><b>:onvalue</b></code></dt>
<dd><p align="right">Name=<code>&quot;<b>onValue</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Value</b>&quot;</code>
</p><br>

<p>Specifies value to store in the button&rsquo;s associated variable whenever
this button is selected.  Defaults to &ldquo;1&rdquo;.
</p></dd>
</dl>


<dl compact="compact">
<dt><code><b>:selector</b></code></dt>
<dd><p align="right">Name=<code>&quot;<b>selector</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Foreground</b>&quot;</code>
</p><br>

<p>Specifies the color to draw in the selector when this button is
selected.
If specified as an empty string then no selector is
drawn for the button.
</p></dd>
</dl>


<dl compact="compact">
<dt><code><b>:state</b></code></dt>
<dd><p align="right">Name=<code>&quot;<b>state</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>State</b>&quot;</code>
</p><br>

<p>Specifies one of three states for the check button:  <b>normal</b><span class="roman">, </span><b>active</b>,
or <b>disabled</b>.  In normal state the check button is displayed using the
<b>foreground</b><span class="roman"> and </span><b>background</b> options.  The active state is
typically used when the pointer is over the check button.  In active state
the check button is displayed using the <b>activeForeground</b> and
<b>activeBackground</b> options.  Disabled state means that the check button
is insensitive:  it doesn&rsquo;t activate and doesn&rsquo;t respond to mouse
button presses.  In this state the <b>disabledForeground</b> and
<b>background</b> options determine how the check button is displayed.
</p></dd>
</dl>


<dl compact="compact">
<dt><code><b>:variable</b></code></dt>
<dd><p align="right">Name=<code>&quot;<b>variable</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Variable</b>&quot;</code>
</p><br>

<p>Specifies name of global variable to set to indicate whether
or not this button is selected.  Defaults to the name of the
button within its parent (i.e. the last element of the button
window&rsquo;s path name).
</p></dd>
</dl>


<dl compact="compact">
<dt><code><b>:width</b></code></dt>
<dd><p align="right">Name=<code>&quot;<b>width</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Width</b>&quot;</code>
</p><br>

<p>Specifies a desired width for the button.
If a bitmap is being displayed in the button then the value is in
screen units (i.e. any of the forms acceptable to <b>Tk_GetPixels</b>);
for text it is in characters.
If this option isn&rsquo;t specified, the button&rsquo;s desired width is computed
from the size of the bitmap or text being displayed in it.
</p></dd>
</dl>

<span id="Description-4"></span><h4 class="unnumberedsubsec">Description</h4>

<p>The <b>checkbutton</b> command creates a new window (given by the
<i>pathName</i> argument) and makes it into a check-button widget.
Additional
options, described above, may be specified on the command line
or in the option database
to configure aspects of the check button such as its colors, font,
text, and initial relief.  The <b>checkbutton</b> command returns its
<i>pathName</i> argument.  At the time this command is invoked,
there must not exist a window named <i>pathName</i>, but
<i>pathName</i>&rsquo;s parent must exist.
</p>
<p>A check button is a widget
that displays a textual string or bitmap
and a square called a <i>selector</i>.
A check button has
all of the behavior of a simple button, including the
following: it can display itself in either of three different
ways, according to the <b>state</b> option;
it can be made to appear
raised, sunken, or flat; it can be made to flash; and it invokes
a Tcl command whenever mouse button 1 is clicked over the
check button.
</p>
<p>In addition, check buttons can be <i>selected</i>.  If a check button is
selected then a special highlight appears in the selector, and
a Tcl variable associated with the check button is set to a particular
value (normally 1).  If the check button is not selected, then
the selector is drawn in a different fashion and the associated
variable is set to a different value (typically 0).  By default,
the name of the variable associated with a check button is the
same as the <i>name</i> used to create the check button.  The
variable name, and the &ldquo;on&rdquo; and &ldquo;off&rdquo; values stored in it,
may be modified with options on the command line or in the option
database.  By default a check button is configured to select and deselect
itself on alternate button clicks.
In addition, each check button monitors its associated variable and
automatically selects and deselects itself when the variables value
changes to and from the button&rsquo;s &ldquo;on&rdquo; value.
</p>
<span id="A-Checkbutton-Widget_0027s-Arguments"></span><h4 class="unnumberedsubsec">A Checkbutton Widget&rsquo;s Arguments</h4>

<p>The <b>checkbutton</b> command creates a new Tcl command whose
name is <i>pathName</i>.  This
command may be used to invoke various
operations on the widget.  It has the following general form:
</p>
<div class="example">
<pre class="example"><i>pathName option </i><span class="roman">?</span><i>arg arg ...</i>?
</pre></div>

<p><i>Option</i><span class="roman"> and the </span><i>arg</i>s
determine the exact behavior of the command.  The following
commands are possible for check button widgets:
</p>
<dl compact="compact">
<dt><i>pathName </i><b>:activate</b></dt>
<dd><p>Change the check button&rsquo;s state to <b>active</b> and redisplay the button
using its active foreground and background colors instead of normal
colors.
This command is ignored if the check button&rsquo;s state is <b>disabled</b>.
This command is obsolete and will eventually be removed;
use &ldquo;<i>pathName </i><b>:configure :state active</b>&rdquo; instead.
</p></dd>
<dt><i>pathName </i><b>:configure</b><span class="roman"> ?</span><i>option</i><span class="roman">? ?</span><i>value option value ...</i>?</dt>
<dd><p>Query or modify the configuration options of the widget.
If no <i>option</i> is specified, returns a list describing all of
the available options for <i>pathName</i><span class="roman"> (see </span><b>Tk_ConfigureInfo</b> for
information on the format of this list).  If <i>option</i> is specified
with no <i>value</i>, then the command returns a list describing the
one named option (this list will be identical to the corresponding
sublist of the value returned if no <i>option</i> is specified).  If
one or more <i>option:value</i> pairs are specified, then the command
modifies the given widget option(s) to have the given value(s);  in
this case the command returns an empty string.
<i>Option</i><span class="roman"> may have any of the values accepted by the </span><b>checkbutton</b>
command.
</p></dd>
<dt><i>pathName </i><b>:deactivate</b></dt>
<dd><p>Change the check button&rsquo;s state to <b>normal</b> and redisplay the button
using its normal foreground and background colors.
This command is ignored if the check button&rsquo;s state is <b>disabled</b>.
This command is obsolete and will eventually be removed;
use &ldquo;<i>pathName </i><b>:configure :state normal</b>&rdquo; instead.
</p></dd>
<dt><i>pathName </i><b>:deselect</b></dt>
<dd><p>Deselect the check button:  redisplay it without a highlight in
the selector and set the associated variable to its &ldquo;off&rdquo;
value.
</p></dd>
<dt><i>pathName </i><b>:flash</b></dt>
<dd><p>Flash the check button.  This is accomplished by redisplaying the check button
several times, alternating between active and normal colors.  At
the end of the flash the check button is left in the same normal/active
state as when the command was invoked.
This command is ignored if the check button&rsquo;s state is <b>disabled</b>.
</p></dd>
<dt><i>pathName </i><b>:invoke</b></dt>
<dd><p>Does just what would have happened if the user invoked the check button
with the mouse: toggle the selection state of the button and invoke
the Tcl command associated with the check button, if there is one.
The return value is the return value from the Tcl command, or an
empty string if there is no command associated with the check button.
This command is ignored if the check button&rsquo;s state is <b>disabled</b>.
</p></dd>
<dt><i>pathName </i><b>:select</b></dt>
<dd><p>Select the check button:  display it with a highlighted
selector and set the associated variable to its &ldquo;on&rdquo;
value.
</p></dd>
<dt><i>pathName </i><b>:toggle</b></dt>
<dd><p>Toggle the selection state of the button, redisplaying it and
modifying its associated variable to reflect the new state.
</p>
</dd>
</dl>
<span id="Bindings-3"></span><h4 class="unnumberedsubsec">Bindings</h4>

<p>Tk automatically creates class bindings for check buttons that give them
the following default behavior:
</p><ul class="no-bullet">
<li> [1]
The check button activates whenever the mouse passes over it and deactivates
whenever the mouse leaves the check button.
</li><li> [2]
The check button&rsquo;s relief is changed to sunken whenever mouse button 1 is
pressed over it, and the relief is restored to its original
value when button 1 is later released.
</li><li> [3]
If mouse button 1 is pressed over the check button and later released over
the check button, the check button is invoked (i.e. its selection
state toggles and the command associated with the button is invoked,
if there is one).  However, if the mouse is not
over the check button when button 1 is released, then no invocation occurs.
</li></ul>

<p>If the check button&rsquo;s state is <b>disabled</b> then none of the above
actions occur:  the check button is completely non-responsive.
</p>
<p>The behavior of check buttons can be changed by defining new bindings for
individual widgets or by redefining the class bindings.
</p>
<span id="Keywords-6"></span><h4 class="unnumberedsubsec">Keywords</h4>
<p>check button, widget
</p><hr>
<div class="header">
<p>
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>
</div>



</body>
</html>