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.
Michael S. (Guest)
on 2009-04-11 18: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
Zhang P. (Guest)
on 2009-04-11 20: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 S. <removed_email_address@domain.invalid>
To: removed_email_address@domain.invalid
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
Alex F. (Guest)
on 2009-04-14 16:33
(Received via mailing list)
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
This topic is locked and can not be replied to.