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