There are a couple of approaches here. All of them require an understanding that MainLoop is just an event loop. That means factoring your code in such a way that it does small chunks of operation at a time. For example:
#instead of:
for (1..100000) {
sleep 1;
}
$mw->update();
#do
for (1..100000) {
sleep 1;
$pb->update($_); #update progressbar
$mw->upddate();
}
One approach is to make a progress bar in your MainWindow, then when finished delete the bar and populate the MainWindow with the widgets that display your results.
Another is to have a "status bar" type area in your results window, show your results window immediately, but with all but the status bar "greyed out" (disabled) until you finish calculating results.
Both of the above only require one MainLoop.
Another approach, and one I'm a big fan of, is to refactor your application as a POE app, and use POE's event loop (which encapsulates a Tk event loop) to manage the various components of your application.
All that said, there is no reason your result window has to be the MainWindow. You could just as easily create a sub window that's displayed near the end of the MainLoop.
How about some code you've tried?
|