GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  TK::AFTER (3)

.ds Aq ’

NAME

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

CONTENTS

SYNOPSIS

$widget-><B>afterB>(ms)

$id = $widget-><B>afterB>(ms?,callback?)

$id = $widget-><B>repeatB>(ms?,callback?)

$widget-><B>afterCancelB>($id)

$id = $widget-><B>afterIdleB>(callback)

$widget-><B>afterInfoB>?($id)?

$id-><B>timeB>(?delay?)

DESCRIPTION

This method is used to delay execution of the program or to execute a callback in background sometime in the future.

In perl/Tk $widget-><B>afterB> is implemented via the class Tk::After, and callbacks are associated with $widget, and are automatically cancelled when the widget is destroyed. An almost identical interface, but without automatic cancel, and without repeat is provided via Tk::after method.

    Internal Details

The internal Tk::After class has the following synopsis:



  $id = Tk::After->new($widget, tid, $time, once,   callback);
  $id = Tk::After->new($widget, tid, $time, repeat, callback);
  $id->cancel;
  $id->time(?delay?);



$id is a Tk::After object, an array of 5 elements:

$widget is the parent widget reference.

tid is the internal timer id, a unique string.

$time is the string ’idle’, representing an idle queue timer, or a integer millisecond value.

once or repeat specifies whether the timer is a one-time <B>afterB> event, or a repeating <B>repeatB> event.

callback specifies a Perl/Tk Tk::Callback object.

Changing a <B>repeatB> timer interval

It’s posible to change a <B>repeatB> timer’s delay value, or even cancel any timer, using the <B>timeB> method. If delay is specified and non-zero, a new timer delay is established. If delay is zero the timer event is canceled just as if $id-><B>cancelB> were invoked. In all cases the current millisecond timer delay is returned.

Note: the new timer delay will take effect on the subsequent timer event - this command will not cancel the pending timer event and re-issue it with the new delay time.

The after() method has several forms as follows:

$widget-><B>afterB>(ms) The value ms must be an integer giving a time in milliseconds. The command sleeps for ms milliseconds and then returns. While the command is sleeping the application does not respond to events.
$widget-><B>afterB>(ms,callback) In this form the command returns immediately, but it arranges for callback be executed ms milliseconds later as an event handler. The callback will be executed exactly once, at the given time. The command will be executed in context of $widget. If an error occurs while executing the delayed command then the Tk::Error mechanism is used to report the error. The <B>afterB> command returns an identifier (an object in the perl/Tk case) that can be used to cancel the delayed command using <B>afterCancelB>.
$widget-><B>repeatB>(ms,callback) In this form the command returns immediately, but it arranges for callback be executed ms milliseconds later as an event handler. After callback has executed it is re-scheduled, to be executed in a futher ms, and so on until it is cancelled.
$widget-><B>afterCancelB>($id)
$id-><B>cancelB> Cancels the execution of a delayed command that was previously scheduled. $id indicates which command should be canceled; it must have been the return value from a previous <B>afterB> command. If the command given by $id has already been executed (and is not scheduled to be executed again) then <B>afterCancelB> has no effect.
$widget-><B>afterCancelB>(callback) This form is not robust in perl/Tk - its use is deprecated. This command should also cancel the execution of a delayed command. The callback argument is compared with pending callbacks, if a match is found, that callback is cancelled and will never be executed; if no such callback is currently pending then the <B>afterCancelB> has no effect.
$widget-><B>afterIdleB>(callback) Arranges for callback 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 <B>afterCancelB>. If an error occurs while executing the script then the Tk::Error mechanism is used to report the error.
$widget-><B>afterInfoB>?($id)? This command returns information about existing event handlers. If no $id argument is supplied, the command returns a list of the identifiers for all existing event handlers created by the <B>afterB> and <B>repeatB> commands for $widget. If $id is supplied, it specifies an existing handler; $id must have been the return value from some previous call to <B>afterB> or <B>repeatB> and it must not have triggered yet or been cancelled. In this case the command returns a list with three elements. The first element of the list is the callback associated with $id, the second element is either <B>idleB> or the integer timer millisecond value to indicate what kind of event handler it is, and the third is a string once or repeat to differentiate an <B>afterB> from a <B>repeatB> event.
The <B>afterB>(ms) and <B>afterIdleB> forms of the command assume that the application is event driven: the delayed commands will not be executed unless the application enters the event loop. In applications that are not normally event-driven, the event loop can be entered with the <B>vwaitB> and <B>updateB> commands.

SEE ALSO

Tk::Error Tk::callbacks

KEYWORDS

cancel, delay, idle callback, sleep, time
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 AFTER (3) 2013-11-15

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.