1after(3)              User Contributed Perl Documentation             after(3)
2
3
4

NAME

6       Tk::after - Execute a command after a time delay
7

SYNOPSIS

9         $widget->after(ms)
10
11         $id = $widget->after(ms?,callback?)
12
13         $id = $widget->repeat(ms?,callback?)
14
15         $widget->afterCancel($id)
16
17         $id = $widget->afterIdle(callback)
18
19         $widget->afterInfo?($id)?
20
21         $id->time(?delay?)
22

DESCRIPTION

24       This method is used to delay execution of the program or to execute a
25       callback in background sometime in the future.
26
27       In perl/Tk $widget->after is implemented via the class "Tk::After", and
28       callbacks are associated with $widget, and are automatically cancelled
29       when the widget is destroyed. An almost identical interface, but
30       without automatic cancel, and without repeat is provided via Tk::after
31       method.
32
33   Internal Details
34       The internal Tk::After class has the following synopsis:
35
36         $id = Tk::After->new($widget, tid, $time, 'once',   callback);
37         $id = Tk::After->new($widget, tid, $time, 'repeat', callback);
38         $id->cancel;
39         $id->time(?delay?);
40
41       $id is a Tk::After object, an array of 5 elements:
42
43       $widget is the parent widget reference.
44
45       tid is the internal timer id, a unique string.
46
47       $time is the string 'idle', representing an idle queue timer, or a
48       integer millisecond value.
49
50       once or repeat specifies whether the timer is a one-time after event,
51       or a repeating repeat event.
52
53       callback specifies a Perl/Tk Tk::Callback object.
54

Changing a repeat timer interval

56       It's posible to change a repeat timer's delay value, or even cancel any
57       timer, using the time method. If delay is specified and non-zero, a new
58       timer delay is established.  If delay is zero the timer event is
59       canceled just as if $id->cancel were invoked.  In all cases the current
60       millisecond timer delay is returned.
61
62       Note: the new timer delay will take effect on the subsequent timer
63       event - this command will not cancel the pending timer event and re-
64       issue it with the new delay time.
65

The after() method has several forms as follows:

67       $widget->after(ms)
68           The value ms must be an integer giving a time in milliseconds.  The
69           command sleeps for ms milliseconds and then returns.  While the
70           command is sleeping the application does not respond to events.
71
72       $widget->after(ms,callback)
73           In this form the command returns immediately, but it arranges for
74           callback be executed ms milliseconds later as an event handler.
75           The callback will be executed exactly once, at the given time.  The
76           command will be executed in context of $widget.  If an error occurs
77           while executing the delayed command then the Tk::Error mechanism is
78           used to report the error.  The after command returns an identifier
79           (an object in the perl/Tk case) that can be used to cancel the
80           delayed command using afterCancel.
81
82       $widget->repeat(ms,callback)
83           In this form the command returns immediately, but it arranges for
84           callback be executed ms milliseconds later as an event handler.
85           After callback has executed it is re-scheduled, to be executed in a
86           futher ms, and so on until it is cancelled.
87
88       $widget->afterCancel($id)
89       $id->cancel
90           Cancels the execution of a delayed command that was previously
91           scheduled.  $id indicates which command should be canceled;  it
92           must have been the return value from a previous after command.  If
93           the command given by $id has already been executed (and is not
94           scheduled to be executed again) then afterCancel has no effect.
95
96       $widget->afterCancel(callback)
97           This form is not robust in perl/Tk - its use is deprecated.  This
98           command should also cancel the execution of a delayed command.  The
99           callback argument is compared with pending callbacks, if a match is
100           found, that callback is cancelled and will never be executed;  if
101           no such callback is currently pending then the afterCancel has no
102           effect.
103
104       $widget->afterIdle(callback)
105           Arranges for callback to be evaluated later as an idle callback.
106           The script will be run exactly once, the next time the event loop
107           is entered and there are no events to process.  The command returns
108           an identifier that can be used to cancel the delayed command using
109           afterCancel.  If an error occurs while executing the script then
110           the Tk::Error mechanism is used to report the error.
111
112       $widget->afterInfo?($id)?
113           This command returns information about existing event handlers.  If
114           no $id argument is supplied, the command returns a list of the
115           identifiers for all existing event handlers created by the after
116           and repeat commands for $widget. If $id is supplied, it specifies
117           an existing handler; $id must have been the return value from some
118           previous call to after or repeat and it must not have triggered yet
119           or been cancelled. In this case the command returns a list with
120           three elements.  The first element of the list is the callback
121           associated with $id, the second element is either idle or the
122           integer timer millisecond value to indicate what kind of event
123           handler it is, and the third is a string once or repeat to
124           differentiate an after from a repeat event.
125
126       The after(ms) and afterIdle forms of the command assume that the
127       application is event driven:  the delayed commands will not be executed
128       unless the application enters the event loop.  In applications that are
129       not normally event-driven, the event loop can be entered with the vwait
130       and update commands.
131

SEE ALSO

133       Tk::Error Tk::callbacks
134

KEYWORDS

136       cancel, delay, idle callback, sleep, time
137
138
139
140perl v5.28.0                      2018-07-15                          after(3)
Impressum