Forum: wxRuby Wx::Timer

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9e6d05909dc733af570faadce1392e67?d=identicon&s=25 Michael Satterwhite (msatterwhite)
on 2009-04-11 16:39
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
A417e097127a89302b7728a7ccb588b4?d=identicon&s=25 Zhang Peng (Guest)
on 2009-04-11 18:40
(Received via mailing list)
Hi Michael,

Try using the following:

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



________________________________
From: Michael Satterwhite <lists@ruby-forum.com>
To: wxruby-users@rubyforge.org
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
06f6780c99d4a8dd71f2b474082ea9ce?d=identicon&s=25 Alex Fenton (Guest)
on 2009-04-14 14:33
(Received via mailing list)
Michael Satterwhite 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
This topic is locked and can not be replied to.