in reply to Updating the Tk::ProgressBar live
pg and zentara are correct that the way to handle this is to explicitly recalculate the progress value and then call $mw->update regularly within your directory processing subroutine. Just by way of explanation, what's happening is that when your callback function addUpdateButtonPressed gets called, the Tk MainLoop is, in effect, suspended until that function returns. This is why you won't see any updates in the progress bar while this is happening. In fact, the entire GUI will essentially be seen to freeze (you can probably see this if you, say, move another window in front of yours and then move it away again). So since MainLoop is no longer processing events for you, you need to call the update method to do it yourself. Don't use repeat - it won't do you much good because you have your own loop doing the work.
The alternative is to use threads. One thread runs the MainLoop but has a repeat call to a sub that will update the progress bar, and the other thread does the real work. But be careful - you cannot simply share the Tk objects between two threads, so you'll have to basically come up with your own communication method.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Updating the Tk::ProgressBar live
by Ace128 (Hermit) on Sep 06, 2005 at 21:29 UTC |