http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/update.htm The [[update]] command is used to bring the application ``up to date'' by entering the [Tcl event loop] repeatedly until all pending events (including idle callbacks) have been processed. ''KBK'' 2000-02-12: My personal opinion is that `update` is not one of the [best practices], and a programmer is well advised to avoid it. I have seldom if ever seen a use of `update` that could not be more effectively programmed by another means, generally appropriate use of event callbacks. By the way, this caution applies to all the Tcl commands (`[vwait]` and `[tkwait]` are the other common culprits) that enter the event loop recursively, with the exception of using a single `[vwait]` at global level to launch the event loop inside a shell that doesn't launch it automatically. If the ''idletasks'' keyword is specified as an argument to the command, then no new events or errors are processed; only idle callbacks are invoked. This causes operations that are normally deferred, such as display updates and window layout calculations, to be performed immediately. ---- ''KBK'' (12 February 2000) -- My personal opinion is that the [[update]] command is not one of the [best practices], and a programmer is well advised to avoid it. I have seldom if ever seen a use of [[update]] that could not be more effectively programmed by another means, generally appropriate use of event callbacks. By the way, this caution applies to all the Tcl commands ([[vwait]] and [[tkwait]] are the other common culprits) that enter the event loop recursively, with the exception of using a single [[vwait]] at global level to launch the event loop inside a shell that doesn't launch it automatically. The commonest purposes for which I've seen `update` recommended are: The commonest purposes for which I've seen [[update]] recommended are: * Waiting for a window to be configured before doing things like geometry management on it. The alternative is to `[bind]` on events such as `` that notify the process of a window's geometry. See [Centering a window] for an alternative. * Waiting for a window to be configured before doing things like geometry management on it. The alternative is to bind on events such as that notify the process of a window's geometry. See [Centering a window] for an alternative. What's wrong with `[update]`? There are several answers. What's wrong with [[update]]? There are several answers. First, it tends to complicate the code of the surrounding GUI. If you work the exercises in the [Countdown program], you'll get a feel for how much easier it can be when each event is processed on its own callback. First, it tends to complicate the code of the surrounding GUI. If you work the exercises in the [Countdown program], you'll get a feel for how much easier it can be when each event is processed on its own callback. Second, it's a source of insidious bugs. The general problem is that executing `update` has nearly unconstrained side effects; on return from `update`, a script can easily discover that the rug has been pulled out from under it. There's further discussion of this phenomenon over at [Update considered harmful]. Second, it's a source of insidious bugs. The general problem is that executing [[update]] has nearly unconstrained side effects; on return from [[update]], a script can easily discover that the rug has been pulled out from under it. There's further discussion of this phenomenon over at [Update considered harmful]. ---- See [event-oriented programming]. ---- [Category Command] from [Tcl] - [Tcl syntax help] - [Arts and Crafts of Tcl-Tk programming]