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?

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law

In reply to Re: Using Tk::ProgressBar by radiantmatrix
in thread Using Tk::ProgressBar by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.