![]() See Countdown program for an alternative. Keeping the GUI alive while some long-running calculation is executing.The commonest purposes for which I’ve seen recommended are: 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 at global level to launch the event loop inside a shell that doesn’t launch it automatically. I have seldom if ever seen a use of that could not be more effectively programmed by another means, generally appropriate use of event callbacks. KBK (12 February 2000) - My personal opinion is that the command is not one of the best practices, and a programmer is well advised to avoid it. This causes operations that are normally deferred, such as display updates and window layout calculations, to be performed immediately. 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. 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. So update_idletasks() causes some subset of events to be processed that update() causes to be processed. Joe English in a posting describes an alternative: ![]() (Redraws due to system events, e.g., being deiconified by the user, need a full update to be processed.)ĪPN As described in Update considered harmful, use of update to handle redraws not handled by update idletasks has many issues. By calling update idletasks, redraws due to internal changes of state are processed immediately. This makes Tk seem much faster, but if you’re in the middle of doing some long running processing, it can also mean that no idle events are processed for a long time. By postponing these until Tk is idle, expensive redraw operations are not done until everything from a cluster of events (e.g., button release, change of current window, etc.) are processed at the script level. Idle events are used to postpone processing until “there is nothing else to do”, with the typical use case for them being Tk’s redrawing and geometry recalculations. ![]() This subcommand of update flushes all currently-scheduled idle events from Tcl’s event queue.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |