Hi all,
I’m looking for a way to get a block of code to execute once a modal
dialog has been displayed (via a call to show_modal.) I was hoping to
find some event that would fire when the window was shown, but the only
one that seemed vaguely promising (evt_window_create) seems to do
nothing
at all, at least in my environment (Ruby 1.9.1 on Win32, wxruby 2.0.1.)
Here’s a very simple (non-modal) example, which fails to print
‘Created!’
as I’d (perhaps naively) expect it to:
require “wx”
class TestFrame < Wx::Frame
def initialize(*args)
super(*args)
puts ‘In Initialize!’
evt_window_create { puts ‘Created!’ }
end
end
class TestApp < Wx::App
def on_init
TestFrame.new(nil, -1, ‘Test!’).show()
end
end
TestApp.new.main_loop
(incidentally, the RubyForge doc page here:
http://wxruby.rubyforge.org/doc/windowcreateevent.html
still refers to this event as ‘evt_create’, which might be worth fixing,
but that’s a different issue.)
I don’t know if I’m misusing this event, or if there’s a bug here
somewhere, but at any rate I’m open to other approaches if this isn’t
the
right way to go. My current solution is an icky hack involving timers
which I’d love to be able to replace with something more sensible. I’m
pretty new to both Ruby and wxRuby, so I apologize in advance if I’m
missing something obvious here.
Ben