develooper Front page | perl.tcltk | Postings from February 2010

Re: Perl/Tkx equivalent to Perl/Tk's 'repeat'

Thread Previous | Thread Next
Michael Carman
February 24, 2010 09:18
Re: Perl/Tkx equivalent to Perl/Tk's 'repeat'
Message ID:
"Swingle David-QWHM86" <> wrote:
> In the following code snippet, I use 'repeat' to call a subroutine
> (UpdateCurrentProgress()) once every 100ms.  Is there something
> equivalent in Perl/Tkx?

No, but it's easy to roll your own:

    # Emulate Perl/Tk's repeat() method
    sub repeat {
        my $ms  = shift;
        my $sub = shift;
        my $repeater; # repeat wrapper
        $repeater = sub { $sub->(@_); Tkx::after($ms, $repeater); };
        Tkx::after($ms, $repeater);

And then use it like this:

    repeat(100, \&UpdateCurrentProgress);


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About