class Iup::Timer
The timer is used to trigger a callback function at regular intervals without interrupting the application’s main event loop. It can be used to safely update the user interface.
For example, the following creates a timer which counts down from 10, updating a label’s title. When the count reaches 0, the application will close.
count = 10 timer = Iup::Timer.new do |t| t.time = 1000 t.action_cb = ->{ if count.zero? Iup::CLOSE else count -= 1 label.title = "Time remaining: #{count}" Iup::DEFAULT end } end
Attributes
Unique reference to widget.
Values ‘yes’ / ‘no’ to start or stop the timer.
The native serial number of the timer: -1 if not running.
Public Class Methods
Source
# File lib/wrapped/timer.rb, line 33 def initialize &block @handle = IupLib.IupTimer # run any provided block on instance, to set up further attributes yield self if block_given? end
Public Instance Methods
Source
# File lib/wrapped/timer.rb, line 41 def destroy IupLib.IupDestroy @handle end
must be called when Timer is finished with
Callbacks
Attributes
Callback called when the time is up. Return Iup::CLOSE to end application. Callback must respond to call and take no arguments.