in reply to Perl Tk Asynchronous Progress Updates

I want to make the progress update asynchronous, but don't know where to start. I suspect the answer involves threads, but I have relatively limited experience using them. On the other hand I feel that using separate threads might be overkill and that there is probably a better way to handle this (though I have yet to find it).

See Re: my within a loop and Tk::after


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Perl Tk Asynchronous Progress Updates

Replies are listed 'Best First'.
Re^2: Perl Tk Asynchronous Progress Updates
by hermes1908 (Novice) on Jul 01, 2013 at 21:59 UTC

    Thanks for the tip. I tried Tk::After, but that doesn't seem to work. Perhaps I misunderstood the cpan page. The modified code is below.

    my $button=$mw->Button(-text=>'Update'); $button->after(0, [\&update, \$prog ]); $button->pack; $mw->ProgressBar(-variable=>\$prog)->pack;

    For some reason the callback function is now executed immediately after the script is run (and still not asynchronously), rather than after the button event. Any help would be much appreciated.

    Thanks

      For some reason the callback function is now executed immediately... $button->after(0, [\&update, \$prog ]);

      What do you think that 0 (zero) that you have as the first argument to ->after() means?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        When I said "immediately" I mean't before the gui is run as opposed to after a button is clicked. I assumed (it appears incorrectly) that tieing the callback via "after" from the button widget would only result in execution upon the widget's activation (button click). This is still my ultimate goal.