|Keep It Simple, Stupid|
Re: Executing functions in Perl::Tkby liverpole (Monsignor)
|on Feb 24, 2010 at 00:49 UTC||Need Help??|
Yes, there are a couple of ways.
The really simple approach is just to call the method update() on the main window object at appropriate times during the subroutine execution:
The more complex (but very powerful) approach is to use threads, as long as you're very careful not to do anything Tk-related within the thread. (That's because Tk is not "thread-safe").
Here's an example of a way you could use threads, especially if there are parts of the worker subroutine that have long delays during which you don't have the luxury of using $mw->update:
Please note that once you're in the worker thread, you must refrain from the urge to use Tk. If you want to pass data back to the main program, you should look into shared data between threads.
If you try putting back in the code where it says "But DON'T do this", you'll get an error message like: