Wx::Timer

I want to process and event at regular time intervals. It appears that
Wx::Timer should do the job, but I haven’t been able to figure out how
to use in in wxruby. The documentation for this is still for C++. I’ve
tried the following:

(In my form class’s initialize method):
@timer = Wx::Timer.new
evt_timer(@timer.id) {|event| onTimer(event)}
@timer.start(1000)

Later in the form, I have the onTimer routine defined. The problem is
that its never being called.

Does anyone know how to use Wx::Timer?

Thanks in advance
—Michael

Hi Michael,

Try using the following:

@timer = Wx::Timer.new(self, -1)
evt_timer(@timer.id, :on_timer)

From: Michael S. [email protected]
To: [email protected]
Sent: Saturday, April 11, 2009 9:39:18 AM
Subject: [wxruby-users] Wx::Timer

I want to process and event at regular time intervals. It appears that
Wx::Timer should do the job, but I haven’t been able to figure out how
to use in in wxruby. The documentation for this is still for C++. I’ve
tried the following:

(In my form class’s initialize method):
@timer = Wx::Timer.new
evt_timer(@timer.id) {|event| onTimer(event)}
@timer.start(1000)

Later in the form, I have the onTimer routine defined. The problem is
that its never being called.

Does anyone know how to use Wx::Timer?

Thanks in advance
—Michael

Michael S. wrote:

I want to process and event at regular time intervals. It appears that
Wx::Timer should do the job, but I haven’t been able to figure out how
to use in in wxruby. The documentation for this is still for C++.

The introductory documentation here:
http://wxruby.rubyforge.org/doc/timer.html is correct for Ruby (though
it seems to have a few formatting errors). For what you want the best
way would be as the first example on that page:

Wx::Timer.every(500) do
puts “Tick”
end

hth
alex