| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
<HTML> |
| 5 |
<HEAD> |
| 6 |
<TITLE>busy(n) manual page</TITLE> |
| 7 |
</HEAD> |
| 8 |
<BODY BGCOLOR="#efefef" TEXT="black" LINK="blue" VLINK="#551A8B" ALINK="red"> |
| 9 |
<A HREF="#toc">Table of Contents</A><P> |
| 10 |
|
| 11 |
<H2><A NAME="sect0" HREF="#toc0">Name</A></H2> |
| 12 |
busy - Make Tk widgets busy, temporarily blocking |
| 13 |
user interactions. |
| 14 |
<H2><A NAME="sect1" HREF="#toc1">Synopsis</A></H2> |
| 15 |
<B>busy hold <I>window</I></B> ?<I>option value</I>?... <P> |
| 16 |
<B>busy release |
| 17 |
<I>window</I></B> ?<I>window</I>?... <P> |
| 18 |
<B>busy configure <I>window</I></B> ?<I>option value</I>?... <P> |
| 19 |
<B>busy forget <I>window</I></B> |
| 20 |
?<I>window</I>?... <P> |
| 21 |
<B>busy isbusy </B>?<I>pattern</I>? <P> |
| 22 |
<B>busy names </B>?<I>pattern</I>? <P> |
| 23 |
<B>busy status <I>window</I></B> |
| 24 |
|
| 25 |
<H2><A NAME="sect2" HREF="#toc2">Description</A></H2> |
| 26 |
<P> |
| 27 |
The <B>busy</B> command provides a simple means to block keyboard, |
| 28 |
button, and pointer events from Tk widgets, while overriding the widget's |
| 29 |
cursor with a configurable busy cursor. |
| 30 |
<H2><A NAME="sect3" HREF="#toc3">Introduction</A></H2> |
| 31 |
<P> |
| 32 |
There are many times |
| 33 |
in applications where you want to temporarily restrict what actions the |
| 34 |
user can take. For example, an application could have a "run" button that |
| 35 |
when pressed causes some processing to occur. But while the application |
| 36 |
is busy processing, you probably don't want the the user to be able to click |
| 37 |
the "run" button again. You may also want restrict the user from other |
| 38 |
tasks such as clicking a "print" button. <P> |
| 39 |
The <B>busy</B> command lets you make |
| 40 |
Tk widgets busy. This means that user interactions such as button clicks, |
| 41 |
moving the mouse, typing at the keyboard, etc. are ignored by the widget. |
| 42 |
You can set a special cursor (like a watch) that overrides the widget's |
| 43 |
normal cursor, providing feedback that the application (widget) is temporarily |
| 44 |
busy. <P> |
| 45 |
When a widget is made busy, the widget and all of its descendents |
| 46 |
will ignore events. It's easy to make an entire panel of widgets busy. You |
| 47 |
can simply make the toplevel widget (such as ".") busy. This is easier and |
| 48 |
far much more efficient than recursively traversing the widget hierarchy, |
| 49 |
disabling each widget and re-configuring its cursor. <P> |
| 50 |
Often, the busy command |
| 51 |
can be used instead of Tk's <B>grab</B> command. Unlike <B>grab</B> which restricts all |
| 52 |
user interactions to one widget, with the busy command you can have more |
| 53 |
than one widget active (for example, a "cancel" dialog and a "help" button). |
| 54 |
|
| 55 |
<H2><A NAME="sect4" HREF="#toc4">Example</A></H2> |
| 56 |
You can make several widgets busy by simply making its ancestor |
| 57 |
widget busy using the <B>hold</B> operation. <BR> |
| 58 |
<CODE>frame .top<BR> |
| 59 |
button .top.button; canvas .top.canvas<BR> |
| 60 |
pack .top.button .top.canvas<BR> |
| 61 |
pack .top<BR> |
| 62 |
. . .<BR> |
| 63 |
busy hold .top<BR> |
| 64 |
update<BR> |
| 65 |
</CODE><P>All the widgets within <I>.top</I> (including <I>.top</I>) are now busy. Using <B>update</B> |
| 66 |
insures that <B>busy</B> command will take effect before any other user events |
| 67 |
can occur. <P> |
| 68 |
When the application is no longer busy processing, you can allow |
| 69 |
user interactions again by the <B>release</B> operation. <BR> |
| 70 |
<PRE><I><tt> </tt> <tt> </tt> busy release .top </I> |
| 71 |
</PRE>The busy window has a configurable cursor. You can change the busy cursor |
| 72 |
using the <B>configure</B> operation. <BR> |
| 73 |
<PRE><I><tt> </tt> <tt> </tt> busy configure .top -cursor "watch"</I> |
| 74 |
</PRE>Finally, when you no longer need to the busy window, invoke the <B>forget</B> |
| 75 |
operation to free any resources it allocated. <BR> |
| 76 |
<PRE><I><tt> </tt> <tt> </tt> busy forget .top </I> |
| 77 |
</PRE>Destroying the widget will also clean up any resources allocated by the |
| 78 |
busy command. <P> |
| 79 |
|
| 80 |
<H2><A NAME="sect5" HREF="#toc5">Operations</A></H2> |
| 81 |
The following operations are available for the <B>busy</B> |
| 82 |
command: |
| 83 |
<DL> |
| 84 |
|
| 85 |
<DT><B>busy hold <I>window</I></B> ?<I>option value</I>?... </DT> |
| 86 |
<DD>Makes the widget <I>window</I> (and its |
| 87 |
descendants in the Tk window hierarchy) busy. <I>Window</I> must be a valid path |
| 88 |
name of a Tk widget. The busy window is mapped the next time idle tasks |
| 89 |
are processed, and the widget and its descendants will be blocked from |
| 90 |
user interactions. All events in the widget window and its descendants are |
| 91 |
ignored. Normally <B>update</B> should be called immediately afterward to insure |
| 92 |
that the <B>hold</B> operation is in effect <I>before</I> the application starts its |
| 93 |
processing. The following configuration options are valid: <blockquote></DD> |
| 94 |
|
| 95 |
<DT><B>-cursor <I>cursorName</I></B> |
| 96 |
</DT> |
| 97 |
<DD>Specifies the cursor to be displayed when the widget is made busy. <I>CursorName</I> |
| 98 |
can be in any form accepted by <B>Tk_GetCursor</B>. The default cursor is <I>watch</I>. |
| 99 |
</DD> |
| 100 |
</DL> |
| 101 |
</blockquote> |
| 102 |
|
| 103 |
<DL> |
| 104 |
|
| 105 |
<DT><B>busy configure <I>window</I></B> ?<I>option value</I>?... </DT> |
| 106 |
<DD>Queries or modifies the <B>busy</B> command |
| 107 |
configuration options for <I>window</I>. <I>Window</I> must be the path name of a widget |
| 108 |
previously made busy by the <B>hold</B> operation. If no options are specified, |
| 109 |
a list describing all of the available options for <I>window</I> (see <B>Tk_ConfigureInfo</B> |
| 110 |
for information on the format of this list) is returned. If <I>option</I> is specified |
| 111 |
with no <I>value</I>, then the command returns a list describing the one named |
| 112 |
option (this list will be identical to the corresponding sublist of the |
| 113 |
value returned if no <I>option</I> is specified). If one or more <I>option-value</I> pairs |
| 114 |
are specified, then the command modifies the given widget option(s) to |
| 115 |
have the given value(s); in this case the command returns the empty string. |
| 116 |
<I>Option</I> may have any of the values accepted by the <B>hold</B> operation. <P> |
| 117 |
Please |
| 118 |
note that the option database is referenced through <I>window</I>. For example, |
| 119 |
if the widget <I>.frame</I> is to be made busy, the busy cursor can be specified |
| 120 |
for it by either <B>option</B> command: <BR> |
| 121 |
<PRE><tt> </tt> <tt> </tt> <I>option add *frame.busyCursor gumby</I> |
| 122 |
<tt> </tt> <tt> </tt> <I>option add *Frame.BusyCursor gumby</I> |
| 123 |
</PRE></DD> |
| 124 |
|
| 125 |
<DT><B>busy forget <I>window</I></B> ?<I>window</I>?... </DT> |
| 126 |
<DD>Releases resources allocated by the busy command |
| 127 |
for <I>window</I>, including the busy window. User events will again be received |
| 128 |
again by <I>window</I>. Resources are also released when <I>window</I> is destroyed. |
| 129 |
<I>Window</I> must be the name of a widget specified in the <B>hold</B> operation, otherwise |
| 130 |
an error is reported. </DD> |
| 131 |
|
| 132 |
<DT><B>busy isbusy </B>?<I>pattern</I>? </DT> |
| 133 |
<DD>Returns the pathnames of all |
| 134 |
widgets that are currently busy. If a <I>pattern</I> is given, the path names of |
| 135 |
busy widgets matching <I>pattern</I> are returned. </DD> |
| 136 |
|
| 137 |
<DT><B>busy names </B>?<I>pattern</I>? </DT> |
| 138 |
<DD>Returns |
| 139 |
the pathnames of all widgets that have previously been made busy (i.e. a |
| 140 |
busy window is allocated and associated with the widget). It makes no difference |
| 141 |
if the window is currently busy or not. If a <I>pattern</I> is given, the path |
| 142 |
names of busy widgets matching <I>pattern</I> are returned. </DD> |
| 143 |
|
| 144 |
<DT><B>busy release <I>window</I></B> |
| 145 |
?<I>window</I>?... </DT> |
| 146 |
<DD>Restores user interactions to the widget <I>window</I> again. This differs |
| 147 |
from the <B>forget</B> operation in that the busy window is not destroyed, but |
| 148 |
simply unmapped. <I>Window</I> must be the name of a widget specified in a <B>hold</B> |
| 149 |
operation, otherwise an error is reported. </DD> |
| 150 |
|
| 151 |
<DT><B>busy status <I>window</I></B> </DT> |
| 152 |
<DD>Returns the |
| 153 |
status of a widget <I>window</I> previously made busy. An error is reported if |
| 154 |
<I>window</I> was never made busy, or the <B>forget</B> operation was invoked (i.e. does |
| 155 |
not currently have a busy window associated with it). If <I>window</I> is presently |
| 156 |
can not receive user interactions, <I>1</I> is returned, otherwise <I>0</I>. <P> |
| 157 |
</DD> |
| 158 |
</DL> |
| 159 |
|
| 160 |
<H2><A NAME="sect6" HREF="#toc6">Bindings</A></H2> |
| 161 |
The |
| 162 |
event blocking feature is implemented by creating and mapping a transparent |
| 163 |
window that completely covers the widget. When the busy window is mapped, |
| 164 |
it invisibly shields the widget and its hierarchy from all events that |
| 165 |
may be sent. Like Tk widgets, busy windows have widget names in the Tk |
| 166 |
window hierarchy. This means that you can use the <B>bind</B> command, to handle |
| 167 |
events in the busy window. <BR> |
| 168 |
<CODE>busy hold .frame.canvas<BR> |
| 169 |
bind .frame.canvas_Busy <Enter> { ... } <BR> |
| 170 |
<P> |
| 171 |
</CODE><P>Normally the busy window is a sibling of the widget. The name of the busy |
| 172 |
window is "<I>widget<I>_Busy</I></I>" where <I>widget</I> is the name of the widget to be made |
| 173 |
busy. In the previous example, the pathname of the busy window is "<I>.frame.canvas_Busy</I>" |
| 174 |
The exception is when the widget is a toplevel widget (such as ".") where |
| 175 |
the busy window can't be made a sibling. The busy window is then a child |
| 176 |
of the widget named "<I>widget<I>._Busy</I></I>" where <I>widget</I> is the name of the toplevel |
| 177 |
widget. In the following example, the pathname of the busy window is "<I>._Busy</I>" |
| 178 |
<BR> |
| 179 |
<CODE>busy hold .<BR> |
| 180 |
bind ._Busy <Enter> { ... } <BR> |
| 181 |
|
| 182 |
<H2><A NAME="sect7" HREF="#toc7"></CODE><P>Enter/Leave Events</A></H2> |
| 183 |
Mapping and unmapping busy windows generates Enter/Leave |
| 184 |
events for all widgets they cover. Please note this if you are tracking |
| 185 |
Enter/Leave events in widgets. |
| 186 |
<H2><A NAME="sect8" HREF="#toc8">Keyboard Events</A></H2> |
| 187 |
When a widget is made busy, |
| 188 |
the widget is prevented from gaining the keyboard focus by the busy window. |
| 189 |
But if the widget already had focus, it still may received keyboard events. |
| 190 |
To prevent this, you must move focus to another window. <BR> |
| 191 |
<CODE>busy hold .frame<BR> |
| 192 |
label .dummy<BR> |
| 193 |
focus .dummy<BR> |
| 194 |
update<BR> |
| 195 |
</CODE><P>The above example moves the focus from .frame immediately after invoking |
| 196 |
the <B>hold</B> so that no keyboard events will be sent to <I>.frame</I> or any of its |
| 197 |
descendants. |
| 198 |
<H2><A NAME="sect9" HREF="#toc9">Keywords</A></H2> |
| 199 |
busy, keyboard events, pointer events, window, cursor |
| 200 |
<P> |
| 201 |
<P> |
| 202 |
<P> |
| 203 |
|
| 204 |
<HR><P> |
| 205 |
<A NAME="toc"><B>Table of Contents</B></A><P> |
| 206 |
<UL> |
| 207 |
<LI><A NAME="toc0" HREF="#sect0">Name</A></LI> |
| 208 |
<LI><A NAME="toc1" HREF="#sect1">Synopsis</A></LI> |
| 209 |
<LI><A NAME="toc2" HREF="#sect2">Description</A></LI> |
| 210 |
<LI><A NAME="toc3" HREF="#sect3">Introduction</A></LI> |
| 211 |
<LI><A NAME="toc4" HREF="#sect4">Example</A></LI> |
| 212 |
<LI><A NAME="toc5" HREF="#sect5">Operations</A></LI> |
| 213 |
<LI><A NAME="toc6" HREF="#sect6">Bindings</A></LI> |
| 214 |
<LI><A NAME="toc7" HREF="#sect7">Enter/Leave Events</A></LI> |
| 215 |
<LI><A NAME="toc8" HREF="#sect8">Keyboard Events</A></LI> |
| 216 |
<LI><A NAME="toc9" HREF="#sect9">Keywords</A></LI> |
| 217 |
</UL> |
| 218 |
</BODY></HTML> |