Updated 2012-01-14 21:42:53 by dkf
after idle script ?script script ...?

Concatenates the script arguments together with space separators (just as in the concat command), and arranges for the resulting script to be evaluated later as an idle callback. The script will be run exactly once, the next time the event loop is entered and there are no events to process. The command returns an identifier that can be used to cancel the delayed command using after cancel. If an error occurs while executing the script then the bgerror mechanism is used to report the error.

A typical use of this command (and perhaps the most important one) is when you need to keep a GUI alive during a long calculation. This is often done with the update command, but this slows down your computation and update is no good choice because: Update considered harmful. Instead use something like
after idle [list after 0 $myCommand]

where $myCommand does one step of a multi-step calculation and calls the above line after having done the single step until all steps are finished. This will smoothly keep your GUI alive and is no performance hit like update or update idletasks.

See also edit


Category Command[Category Tcl syntax help]