in reply to Creating a non-UI event in Perl/Tk

I would normaly go with gri6507's solution, $mw->update() will display the main window and return when any events are done (there should be very few with out any user interaction).
An alternative is to use Tk::after, from it's POD:
$widget->after(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 after command returns an identifier (an object in the perl/Tk case) that can be used to cancel the delayed command using afterCancel.
The downside is you will either have to break up your proccessing into chunks, so that Tk can be given controll to update it's window, or you will still need to call $mw->update() to do that your self.

Replies are listed 'Best First'.
Re^2: Creating a non-UI event in Perl/Tk
by radiantmatrix (Parson) on Sep 22, 2004 at 17:02 UTC
    Thank you! I now do this, and it solves my issue:
    my $mw = Tk::MainWindow; # set up all the widgets... $mw->after(0,\&main_loop); sub main_loop { ... }
    Each iteration of the loop is a few ms, and I call $mw->update after adjusting the ProgressBar once each loop. Works like a charm, thank you again!
    --
    $me = rand($hacker{perl});

    All code, unless otherwise noted, is untested
    "All it will give you though, are headaches after headaches as it misinterprets your instructions in the most innovative yet useless ways." - Maypole and I - Tales from the Frontier of a Relationship (by Corion)