Debian Codegraph @

info/gcl-tk/button.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>button (GCL TK Manual)</title>
7
8 <meta name="description" content="button (GCL TK Manual)">
9 <meta name="keywords" content="button (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="listbox.html" rel="next" title="listbox">
17 <link href="Widgets.html" rel="prev" title="Widgets">
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="button"></span><div class="header">
42 <p>
43 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>
44 </div>
45 <hr>
46 <span id="button-1"></span><h3 class="section">2.1 button</h3>
47
48 <p>button \- Create and manipulate button widgets
49 </p><span id="Synopsis"></span><h4 class="unnumberedsubsec">Synopsis</h4>
50 <p><b>button</b><i> </i><i>pathName </i><span class="roman">?</span><i>options</i>?
51 </p><span id="Standard-Options"></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-Button"></span><h4 class="unnumberedsubsec">Arguments for Button</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.
74 </p></dd>
75 </dl>
76
77
78 <dl compact="compact">
79 <dt><code><b>:height</b></code></dt>
80 <dd><p align="right">Name=<code>&quot;<b>height</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Height</b>&quot;</code>
81 </p><br>
82
83 <p>Specifies a desired height for the button.
84 If a bitmap is being displayed in the button then the value is in
85 screen units (i.e. any of the forms acceptable to <b>Tk_GetPixels</b>);
86 for text it is in lines of text.
87 If this option isn&rsquo;t specified, the button&rsquo;s desired height is computed
88 from the size of the bitmap or text being displayed in it.
89 </p></dd>
90 </dl>
91
92
93 <dl compact="compact">
94 <dt><code><b>:state</b></code></dt>
95 <dd><p align="right">Name=<code>&quot;<b>state</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>State</b>&quot;</code>
96 </p><br>
97
98 <p>Specifies one of three states for the button: <b>normal</b><span class="roman">, </span><b>active</b>,
99 or <b>disabled</b>. In normal state the button is displayed using the
100 <b>foreground</b><span class="roman"> and </span><b>background</b> options. The active state is
101 typically used when the pointer is over the button. In active state
102 the button is displayed using the <b>activeForeground</b> and
103 <b>activeBackground</b> options. Disabled state means that the button
104 is insensitive: it doesn&rsquo;t activate and doesn&rsquo;t respond to mouse
105 button presses. In this state the <b>disabledForeground</b> and
106 <b>background</b> options determine how the button is displayed.
107 </p></dd>
108 </dl>
109
110
111 <dl compact="compact">
112 <dt><code><b>:width</b></code></dt>
113 <dd><p align="right">Name=<code>&quot;<b>width</b><span class="roman">&quot;</span> Class=<code>&quot;</code><b>Width</b>&quot;</code>
114 </p><br>
115
116 <p>Specifies a desired width for the button.
117 If a bitmap is being displayed in the button then the value is in
118 screen units (i.e. any of the forms acceptable to <b>Tk_GetPixels</b>);
119 for text it is in characters.
120 If this option isn&rsquo;t specified, the button&rsquo;s desired width is computed
121 from the size of the bitmap or text being displayed in it.
122 </p></dd>
123 </dl>
124
125 <span id="Description"></span><h4 class="unnumberedsubsec">Description</h4>
126
127 <p>The <b>button</b> command creates a new window (given by the
128 <i>pathName</i> argument) and makes it into a button widget.
129 Additional
130 options, described above, may be specified on the command line
131 or in the option database
132 to configure aspects of the button such as its colors, font,
133 text, and initial relief. The <b>button</b> command returns its
134 <i>pathName</i> argument. At the time this command is invoked,
135 there must not exist a window named <i>pathName</i>, but
136 <i>pathName</i>&rsquo;s parent must exist.
137 </p>
138 <p>A button is a widget
139 that displays a textual string or bitmap.
140 It can display itself in either of three different ways, according
141 to
142 the <b>state</b> option;
143 it can be made to appear raised, sunken, or flat;
144 and it can be made to flash. When a user invokes the
145 button (by pressing mouse button 1 with the cursor over the
146 button), then the Tcl command specified in the <b>:command</b>
147 option is invoked.
148 </p>
149 <span id="A-Button-Widget_0027s-Arguments"></span><h4 class="unnumberedsubsec">A Button Widget&rsquo;s Arguments</h4>
150
151 <p>The <b>button</b> command creates a new Tcl command whose
152 name is <i>pathName</i>. This
153 command may be used to invoke various
154 operations on the widget. It has the following general form:
155 </p>
156 <div class="example">
157 <pre class="example"><i>pathName option </i><span class="roman">?</span><i>arg arg ...</i>?
158 </pre></div>
159
160 <p><i>Option</i><span class="roman"> and the </span><i>arg</i>s
161 determine the exact behavior of the command. The following
162 commands are possible for button widgets:
163 </p>
164 <dl compact="compact">
165 <dt><i>pathName </i><b>:activate</b></dt>
166 <dd><p>Change the button&rsquo;s state to <b>active</b> and redisplay the button
167 using its active foreground and background colors instead of normal
168 colors.
169 This command is ignored if the button&rsquo;s state is <b>disabled</b>.
170 This command is obsolete and will eventually be removed;
171 use &ldquo;<i>pathName </i><b>:configure :state active</b>&rdquo; instead.
172 </p></dd>
173 <dt><i>pathName </i><b>:configure</b><span class="roman"> ?</span><i>option</i><span class="roman">? ?</span><i>value option value ...</i>?</dt>
174 <dd><p>Query or modify the configuration options of the widget.
175 If no <i>option</i> is specified, returns a list describing all of
176 the available options for <i>pathName</i><span class="roman"> (see </span><b>Tk_ConfigureInfo</b> for
177 information on the format of this list). If <i>option</i> is specified
178 with no <i>value</i>, then the command returns a list describing the
179 one named option (this list will be identical to the corresponding
180 sublist of the value returned if no <i>option</i> is specified). If
181 one or more <i>option:value</i> pairs are specified, then the command
182 modifies the given widget option(s) to have the given value(s); in
183 this case the command returns an empty string.
184 <i>Option</i><span class="roman"> may have any of the values accepted by the </span><b>button</b>
185 command.
186 </p></dd>
187 <dt><i>pathName </i><b>:deactivate</b></dt>
188 <dd><p>Change the button&rsquo;s state to <b>normal</b> and redisplay the button
189 using its normal foreground and background colors.
190 This command is ignored if the button&rsquo;s state is <b>disabled</b>.
191 This command is obsolete and will eventually be removed;
192 use &ldquo;<i>pathName </i><b>:configure :state normal</b>&rdquo; instead.
193 </p></dd>
194 <dt><i>pathName </i><b>:flash</b></dt>
195 <dd><p>Flash the button. This is accomplished by redisplaying the button
196 several times, alternating between active and normal colors. At
197 the end of the flash the button is left in the same normal/active
198 state as when the command was invoked.
199 This command is ignored if the button&rsquo;s state is <b>disabled</b>.
200 </p></dd>
201 <dt><i>pathName </i><b>:invoke</b></dt>
202 <dd><p>Invoke the Tcl command associated with the button, if there is one.
203 The return value is the return value from the Tcl command, or an
204 empty string if there is no command associated with the button.
205 This command is ignored if the button&rsquo;s state is <b>disabled</b>.
206 </p>
207 </dd>
208 </dl>
209 <span id="g_t_0022Default-Bindings_0022"></span><h4 class="unnumberedsubsec">&quot;Default Bindings&quot;</h4>
210
211 <p>Tk automatically creates class bindings for buttons that give them
212 the following default behavior:
213 </p><ul class="no-bullet">
214 <li> [1]
215 The button activates whenever the mouse passes over it and deactivates
216 whenever the mouse leaves the button.
217 </li><li> [2]
218 The button&rsquo;s relief is changed to sunken whenever mouse button 1 is
219 pressed over the button, and the relief is restored to its original
220 value when button 1 is later released.
221 </li><li> [3]
222 If mouse button 1 is pressed over the button and later released over
223 the button, the button is invoked. However, if the mouse is not
224 over the button when button 1 is released, then no invocation occurs.
225 </li></ul>
226
227 <p>If the button&rsquo;s state is <b>disabled</b> then none of the above
228 actions occur: the button is completely non-responsive.
229 </p>
230 <p>The behavior of buttons can be changed by defining new bindings for
231 individual widgets or by redefining the class bindings.
232 </p>
233 <span id="Keywords"></span><h4 class="unnumberedsubsec">Keywords</h4>
234 <p>button, widget
235 </p><hr>
236 <div class="header">
237 <p>
238 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>
239 </div>
240
241
242
243 </body>
244 </html>