Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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?

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

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2021-09-28 07:00 GMT
Find Nodes?
    Voting Booth?

    No recent polls found