<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://www.tcl.tk/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Wed May 22 02:27:14 GMT 2013 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='321'>
<header><title>Add a [tk busy] Command</title><author address="mailto:jos.decoster@gmail.com">Jos Decoster</author><status type='project' state='final' tclversion="8.6" vote='after'>$Revision: 1.6 $</status><history></history><created day='26' month='jun' year='2008' /><keyword>Tk BLT busy</keyword></header>
<abstract>The <emph style="bold">blt::busy</emph> commands can be used to make Tk widget busy, with all user interaction blocked and the cursor can be changed to e.g. a clock. This TIP proposes to add this useful feature to Tk.</abstract>
<body><section title="Rationale">
<para>BLT has a lot of very useful commands: <emph style="bold">bgexec</emph>, <emph style="bold">busy</emph>, <emph style="bold">vector</emph>, <emph style="bold">graph</emph> widget, <emph style="bold">barchart</emph> widget, ... But getting BLT to work with the latest releases of Tcl and Tk becomes more and more difficult. Some of the problems I experienced are:</para>
<itemize><item.i><para>internal Tk structures are mirrored</para></item.i><item.i><para>interaction with xft fails, so Tk has to be build without xft support</para></item.i><item.i><para>the build process is different from the one used in Tcl and Tk</para></item.i></itemize>
<para>Discussions on CLT and #tcl indicated that extracting functionality from BLT and add it to Tcl and Tk might be a good way to make the blt commands available for every Tcl programmer.</para>
<para>This TIP proposes a way to add the blt::busy command to Tk, based on the code as found in BLT2.4z and the code as found in busy.kit. While adding the code to Tk, it was rewritten to use the Tcl_Obj interface and the new option interface. The interface has also been simplified. The <emph style="bold">blt::release</emph> command was not withheld. Because often the same window is made busy again and again, using <emph style="bold">release</emph> in stead of <emph style="bold">forget</emph> might be faster. But when making an application busy, it&apos;s because it&apos;ll have to wait for another operation and/or process to finish which will typically take a much longer time than the time needed to (re)create the transparent window. The <emph style="bold">names</emph> and <emph style="bold">isbusy</emph> commands were replaced by the new <emph style="bold">current</emph> command. The confusing difference between a window which is busy, a window which was busy but still has the associated transparent window allocated and a window which was busy but no longer has its associated transparent window allocated was removed.</para>
<para>The name of this new Tk command as currently implemented is <emph style="bold">tk busy</emph>, part of the <emph style="bold">tk</emph> command ensemble. Adding it as an option to the <emph style="bold">grab</emph> command might cause confusion as the <emph style="bold">tk busy</emph> command has the opposite functionality of the <emph style="bold">grab</emph> command. It blocks all user interaction rather than redirecting it to one widget.</para>
</section>
<section title="Specification">
<para>The <emph style="bold">tk busy</emph> command is an ensemble with a special feature that any unrecognized subcommand that starts with a period is treated as an invokation of the <emph style="bold">hold</emph> subcommand upon the widget with that name.</para>
<subsection title="Hold Subcommand">
<quote><emph style="bold">tk busy</emph> <emph style="italic">window</emph> ?<emph style="italic">option value</emph>?</quote>
<quote><emph style="bold">tk busy hold</emph> <emph style="italic">window</emph> ?<emph style="italic">option value</emph>?</quote>
<para>Makes the window (and its descendants in the Tk window hierarchy) appear busy by ignoring all events sent to the window and its descendants. <emph style="italic">Window</emph> must be a valid path name of a Tk widget. A transparent window is put in front of the specified window. This transparent window is mapped the next time idle tasks are processed, and the specified window and its descendants will be blocked from user interactions. Normally update should be called immediately afterward to insure that the hold operation is in effect before the application starts its processing. The following configuration options are valid:</para>
<quote><emph style="bold">-cursor</emph> <emph style="italic">cursorName</emph> </quote>
<para>Specifies the cursor to be displayed when the widget is made busy. CursorName can be in any form accepted by Tk_GetCursor. The default cursor is watch.</para>
</subsection>
<subsection title="Forget Subcommand">
<quote><emph style="bold">tk busy forget</emph> <emph style="italic">window</emph></quote>
<para>Releases resources allocated by the <emph style="bold">tk busy</emph> command for <emph style="italic">window</emph>, including the transparent window. User events will again be received by the specified window. Resources are also released when the specified window is destroyed. <emph style="italic">Window</emph> must be the name of a widget previously specified in a <emph style="bold">hold</emph> operation, otherwise an error is reported.</para>
</subsection>
<subsection title="Current Subcommand">
<quote><emph style="bold">tk busy current</emph> ?<emph style="italic">pattern</emph>?</quote>
<para>Returns the pathnames of all windows that are currently made busy. If a <emph style="italic">pattern</emph> is given, only the path names of busy windows matching <emph style="italic">pattern</emph> are returned.</para>
</subsection>
<subsection title="Status Subcommand">
<quote><emph style="bold">tk busy status</emph> <emph style="italic">window</emph></quote>
<para>Returns the busy status of a <emph style="italic">window</emph>. If <emph style="italic">window</emph> presently can not receive user interactions, 1 is returned, otherwise 0.</para>
</subsection>
<subsection title="Configure Subcommand">
<quote><emph style="bold">tk busy configure</emph> <emph style="italic">window</emph> ?<emph style="italic">option</emph>? ?<emph style="italic">value ...</emph>?</quote>
<para>Queries or modifies the <emph style="bold">tk busy</emph> command configuration options for <emph style="italic">window</emph>. <emph style="italic">Window</emph> must be the path name of a widget previously made busy by the <emph style="bold">hold</emph> operation. If no options are specified, a list describing all of the available options for window (see <emph style="bold">Tk_ConfigureInfo</emph> for information on the format of this list) is returned. If <emph style="italic">option</emph> is specified with no <emph style="italic">value</emph>, 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 option is specified). If one or more <emph style="italic">option-value</emph> pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns the empty string. Options may have any of the values accepted by the hold operation.</para>
<para>Please note that the option database is referenced through window. For example, if the widget .frame is to be made busy, the busy cursor can be specified for it by either option command:</para>
<verbatim><vline encoding='base64'>ICAgICAgICBvcHRpb24gYWRkICpmcmFtZS5idXN5Q3Vyc29yIGd1bWJ5</vline><vline encoding='base64'>ICAgICAgICBvcHRpb24gYWRkICpGcmFtZS5CdXN5Q3Vyc29yIGd1bWJ5</vline></verbatim>
</subsection>
<subsection title="Cget Subcommand">
<quote><emph style="bold">tk busy cget</emph> <emph style="italic">window option</emph></quote>
<para>Queries the <emph style="bold">tk busy</emph> command configuration options for <emph style="italic">window</emph>. <emph style="italic">Window</emph> must be the path name of a widget previously made busy by the <emph style="bold">hold</emph> operation. The command returns the present value of the specified <emph style="italic">option</emph>. <emph style="italic">Option</emph> may have any of the values accepted by the <emph style="bold">hold</emph> operation.</para>
</subsection>
</section>
<section title="Reference Implementation">
<para>See SourceForge patch #1997907 [<url ref="https://sourceforge.net/support/tracker.php?aid=1997907"/>]. There is no support for Mac + Aqua in this patch. It compiles on Mac + Aqua and the command will not return errors but will not resort in a <emph style="italic">busy</emph> effect. Mac + X11 does work.</para>
</section>
<section title="Compatibility">
<para>Because the command as proposed above has the same interface and behavior as the <emph style="bold">blt::busy</emph> command, replacing <emph style="bold">blt::busy</emph> with <emph style="bold">tk busy</emph> is all that&apos;s needed to switch to the Tk version of the busy command.</para>
<para>The <emph style="bold">tk busy</emph> command is not one-by-one compatible with the <emph style="bold">blt::busy</emph> command, but typical use (<emph style="bold">hold</emph> and <emph style="bold">forget</emph>) will not suffer a lot. Aliases or an ensemble could be used to make transition easier.</para>
</section>
<section title="Alternatives">
<para>The busy command is available as starkit from <url ref="http://tcl.tk/starkits/busy.kit"/></para>
<para>An alternative would have been to keep the interface from BLT. This would have made transition easier, but would have kept the confusing difference between <emph style="italic">forgotten</emph> and <emph style="italic">released</emph> busy windows.</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>
