Class: Wx::Timer

Inherits:
Object
  • Object
show all
Defined in:
lib/wx/classes/timer.rb

Overview

Class allowing periodic or timed events to be fired

Class Method Summary collapse

Class Method Details

.after(interval, &block) ⇒ Object

Convenience method to trigger a one-off action after interval milliseconds have passed. The action is specified by the passed block. The Timer is owned by the global App object, and is returned by the method.



7
8
9
10
11
12
# File 'lib/wx/classes/timer.rb', line 7

def self.after(interval, &block)
  timer = new(Wx::THE_APP, Wx::ID_ANY)
  Wx::THE_APP.evt_timer(timer.get_id, block)
  timer.start(interval, true)
  timer
end

.every(interval, &block) ⇒ Object

Convenience method to trigger a repeating action every interval milliseconds. The action is specified by the passed block. The Timer is owned by the global App object, and is returned by the method.



17
18
19
20
21
22
# File 'lib/wx/classes/timer.rb', line 17

def self.every(interval, &block)
  timer = new(Wx::THE_APP, Wx::ID_ANY)
  Wx::THE_APP.evt_timer(timer.get_id, block)
  timer.start(interval)
  timer
end