| 1 |
'\" |
| 2 |
'\" Copyright (c) 1990-1992 The Regents of the University of California. |
| 3 |
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc. |
| 4 |
'\" |
| 5 |
'\" See the file "license.terms" for information on usage and redistribution |
| 6 |
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 7 |
'\" |
| 8 |
.TH update n 7.5 Tcl "Tcl Built-In Commands" |
| 9 |
.so man.macros |
| 10 |
.BS |
| 11 |
'\" Note: do not modify the .SH NAME line immediately below! |
| 12 |
.SH NAME |
| 13 |
update \- Process pending events and idle callbacks |
| 14 |
.SH SYNOPSIS |
| 15 |
\fBupdate\fR ?\fBidletasks\fR? |
| 16 |
.BE |
| 17 |
.SH DESCRIPTION |
| 18 |
.PP |
| 19 |
This command is used to bring the application |
| 20 |
.QW "up to date" |
| 21 |
by entering the event loop repeatedly until all pending events |
| 22 |
(including idle callbacks) have been processed. |
| 23 |
.PP |
| 24 |
If the \fBidletasks\fR keyword is specified as an argument to the |
| 25 |
command, then no new events or errors are processed; only idle |
| 26 |
callbacks are invoked. |
| 27 |
This causes operations that are normally deferred, such as display |
| 28 |
updates and window layout calculations, to be performed immediately. |
| 29 |
.PP |
| 30 |
The \fBupdate idletasks\fR command is useful in scripts where |
| 31 |
changes have been made to the application's state and you want those |
| 32 |
changes to appear on the display immediately, rather than waiting |
| 33 |
for the script to complete. Most display updates are performed as |
| 34 |
idle callbacks, so \fBupdate idletasks\fR will cause them to run. |
| 35 |
However, there are some kinds of updates that only happen in |
| 36 |
response to events, such as those triggered by window size changes; |
| 37 |
these updates will not occur in \fBupdate idletasks\fR. |
| 38 |
.PP |
| 39 |
The \fBupdate\fR command with no options is useful in scripts where |
| 40 |
you are performing a long-running computation but you still want |
| 41 |
the application to respond to events such as user interactions; if |
| 42 |
you occasionally call \fBupdate\fR then user input will be processed |
| 43 |
during the next call to \fBupdate\fR. |
| 44 |
.SH EXAMPLE |
| 45 |
.PP |
| 46 |
Run computations for about a second and then finish: |
| 47 |
.PP |
| 48 |
.CS |
| 49 |
set x 1000 |
| 50 |
set done 0 |
| 51 |
after 1000 set done 1 |
| 52 |
while {!$done} { |
| 53 |
# A very silly example! |
| 54 |
set x [expr {log($x) ** 2.8}] |
| 55 |
|
| 56 |
# Test to see if our time-limit has been hit. This would |
| 57 |
# also give a chance for serving network sockets and, if |
| 58 |
# the Tk package is loaded, updating a user interface. |
| 59 |
\fBupdate\fR |
| 60 |
} |
| 61 |
.CE |
| 62 |
.SH "SEE ALSO" |
| 63 |
after(n), interp(n) |
| 64 |
.SH KEYWORDS |
| 65 |
asynchronous I/O, event, flush, handler, idle, update |