File: button.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 (244 lines) | stat: -rw-r--r-- 10,688 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
<!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>button (GCL TK Manual)</title>

<meta name="description" content="button (GCL TK Manual)">
<meta name="keywords" content="button (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="listbox.html" rel="next" title="listbox">
<link href="Widgets.html" rel="prev" title="Widgets">
<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="button"></span><div class="header">
<p>
Next: <a href="listbox.html" accesskey="n" rel="next">listbox</a>, Previous: <a href="Widgets.html" accesskey="p" rel="prev">Widgets</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="button-1"></span><h3 class="section">2.1 button</h3>

<p>button \- Create and manipulate button widgets
</p><span id="Synopsis"></span><h4 class="unnumberedsubsec">Synopsis</h4>
<p><b>button</b><i> </i><i>pathName </i><span class="roman">?</span><i>options</i>?
</p><span id="Standard-Options"></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-Button"></span><h4 class="unnumberedsubsec">Arguments for Button</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.
</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>: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 button:  <b>normal</b><span class="roman">, </span><b>active</b>,
or <b>disabled</b>.  In normal state the 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 button.  In active state
the button is displayed using the <b>activeForeground</b> and
<b>activeBackground</b> options.  Disabled state means that the 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 button is displayed.
</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"></span><h4 class="unnumberedsubsec">Description</h4>

<p>The <b>button</b> command creates a new window (given by the
<i>pathName</i> argument) and makes it into a button widget.
Additional
options, described above, may be specified on the command line
or in the option database
to configure aspects of the button such as its colors, font,
text, and initial relief.  The <b>button</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 button is a widget
that displays a textual string or bitmap.
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;
and it can be made to flash.  When a user invokes the
button (by pressing mouse button 1 with the cursor over the
button), then the Tcl command specified in the <b>:command</b>
option is invoked.
</p>
<span id="A-Button-Widget_0027s-Arguments"></span><h4 class="unnumberedsubsec">A Button Widget&rsquo;s Arguments</h4>

<p>The <b>button</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 button widgets:
</p>
<dl compact="compact">
<dt><i>pathName </i><b>:activate</b></dt>
<dd><p>Change the 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 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>button</b>
command.
</p></dd>
<dt><i>pathName </i><b>:deactivate</b></dt>
<dd><p>Change the 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 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>:flash</b></dt>
<dd><p>Flash the button.  This is accomplished by redisplaying the button
several times, alternating between active and normal colors.  At
the end of the flash the button is left in the same normal/active
state as when the command was invoked.
This command is ignored if the button&rsquo;s state is <b>disabled</b>.
</p></dd>
<dt><i>pathName </i><b>:invoke</b></dt>
<dd><p>Invoke the Tcl command associated with the 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 button.
This command is ignored if the button&rsquo;s state is <b>disabled</b>.
</p>
</dd>
</dl>
<span id="g_t_0022Default-Bindings_0022"></span><h4 class="unnumberedsubsec">&quot;Default Bindings&quot;</h4>

<p>Tk automatically creates class bindings for buttons that give them
the following default behavior:
</p><ul class="no-bullet">
<li> [1]
The button activates whenever the mouse passes over it and deactivates
whenever the mouse leaves the button.
</li><li> [2]
The button&rsquo;s relief is changed to sunken whenever mouse button 1 is
pressed over the button, 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 button and later released over
the button, the button is invoked.  However, if the mouse is not
over the button when button 1 is released, then no invocation occurs.
</li></ul>

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