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? -- Posted via http://www.ruby-forum.com/.
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