[wxruby-users] wxRuby dialog separate from main Ruby script execution

Alex Fenton alex at pressure.to
Thu Jan 15 06:29:10 EST 2009


David Muir wrote:
> My current problem is that when the wxRuby's main_loop is invoked no
> Ruby code gets executed.  Is there any way around this?  Or is this a
> limitation of using wxRuby?

It's a limitation of Ruby 1.8's green threads with C-based event loops. 
There is a workaround - add something like this in your App.run block / 
App#on_init method:

Wx::Timer.every(25) { Thread.pass }

Alternately, use Ruby 1.9 which I find does not have this problem, 
because there are real system threads underneath Ruby threads. However 
you should not update a GUI from the non-main thread.

For further, have a look at the etc/threaded.rb sample in the 
distribution, and previous discussions on this list on wxRuby + threads.

hth
a




More information about the wxruby-users mailing list