From: Lyle Johnson Date: 2002-09-16T11:48:11+09:00 Subject: Re: FXProgressbar: how to update during lengthy task "Joel VanderWerf" wrote in message news:3D83A5C4.5090806@path.berkeley.edu... > There's surely an easy answer to this. How do you update a progress bar > during a lengthy calculation? The examples that come with FXRuby only > have a process bar updated while the app is idle. Because all of the progress bar updating is taking place in the onCmdSave() callback the main event loop doesn't have a chance to process the repaint events until it returns. So basically, we need to do something to "nudge" the FOX event loop to go ahead and do its thing right away, as soon as you've updated the progress value. One approach (the one you're using) is to update the value of a data target associated with the progress bar. Since FOX's GUI update mechanism is the magic that happens under the hood to make data targets work, we want FOX to go ahead and do a "GUI update" pass as soon as you've changed the data target's value. When that happens, the progress bar will look at its data target, grab the new value and repaint itself. To accomplish this just add a call to getApp().forceRefresh in the loop: def onCmdSave(sender, sel, ptr) 20.times { |i| sleep(0.1) @progress_target.value = i getApp().forceRefresh } return 1 end A different tack, assuming you didn't use a data target for the progress, would be to just call FXProgressBar#progress=() directly in the loop: def onCmdSave(sender, sel, ptr) 20.times { |i| sleep(0.1) @progress_bar.progress = i } return 1 end Note that in this case we're not relying on the GUI update mechanism to get the progress bar to ask its data target what the current value is, so there's no need to force a refresh walk. Hope this helps, Lyle