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

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

Thread Previous | Thread Next
From:
Michael Carman
Date:
February 24, 2010 09:18
Subject:
Re: Perl/Tkx equivalent to Perl/Tk's 'repeat'
Message ID:
2049140462.6504171267031855463.JavaMail.root@dsmdc-mail-mbs13
"Swingle David-QWHM86" <dswingle@motorola.com> 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);

-mjc


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About