Your problem is going to force you to get down into the code, and understand how the Tk-event-loop works. Think about how a "single-threaded process" runs.....it can only be doing one thing at a time, unless you figure out a way to time slice the execution, to process sub1 for x microseconds, then sub2 for x microseconds, etc,etc. That is why in a Tk (or any gui program), if you run "sleep" or system(), the GUI stops updating while the system command does it's work. So what is happening in your code, is that when you hit the line "my $result= MyParser->new($file)"; the process devotes all it's time to running that, and Tk is left with no cpu time. So there are many ways devised to work around it. One would be to go into the MyParser package, and put a "$mw->update" in the loop that processes the file. Now in order to make it work, you may need to pass "$mw" into the package when it is created. Other things can be done, but you havn't showed the MyParser code. You could run the parser in a thread, a piped open, or IPC::Open3, and alot of examples for doing that abound. If you cannot change the MyParser package to do some $mw->update's, you could start the Progressbar,
then "fork-and-exec" the code that parse the file, and when the parsing is done, cancel the repeat. Of course you will lose
percentage accuracy that way, but threads would allow it. Just remember, if you use a thread with Tk, the thread must be created before you create any Tk windows. I usually create a thread, put it to sleep, and control it from Tk thru shared variables. An example is in the readmore.
I'm not really a human, but I play one on earth.
flash japh
| [reply] [Watch: Dir/Any] [d/l] |