Hi, I am using the Gauge for the first time, and am confused on it's use. I want to use it to measure the progress of copying certain files from one location to another. It is inside a Frame. The problem is, that if I try to update the position after Frame.show, the program ends. Can anyone link to an example? (The included bigdemo.rb didn't help, because it uses a Timer to change the position) Thanks, Jonah
on 2009-05-04 01:22
on 2009-05-04 03:12
It would be helpful, if you provided a minimalistic version of your program, demonstrating the problem, so that we can properly diagnose it.
on 2009-05-04 17:01
Sorry, never mind. It was an error in my code. On a side note, how does one loop through a process while moving the gauge, without freezing the program? If I loop through copying some files, it still moves the gauge, but has a waiting cursor and is stuck. Is there a way to make it do the operation, but not freeze?
on 2009-05-04 20:47
Jonah Dahlquist wrote: > how does one loop through a process while moving the gauge, without freezing > the program? If I loop through copying some files, it still moves the > gauge, but has a waiting cursor and is stuck. Is there a way to make it > do the operation, but not freeze? > There are several different ways to deal with long-running background tasks. Probably the easiest one for this situation - where you have a job that breaks down naturally into smaller pieces (individual files) - is to use evt_idle. This is called whenever there is processing time free. It would go something like this: def initialize ... evt_idle :on_idle end def on_idle if have_files_to_copy copy_a_file update_progress_bar end end This should allow the task to progress in chunks while keeping the GUI responsive. A more general approach to dealing with long-running tasks is to run them in a background Thread. But this is considerably more complicated for several reasons - eg you should not make GUI update calls from subordinate threads. There are previous discussions and samples about using Threads in wxRuby if that's the way you want to go. alex
on 2009-05-04 21:41
Perfect! It works now. Thanks :)