10.16. timer

It is often required to repeatedly call a specific function or method with a certain time interval. This can be done using the class timer. See the example timerExample.py in the demo folder for what the timer can be used. The method or function can either be called once after a certain interval (single shot timer) or repeatedly with a given interval. In both cases, the variable that references the timer instance must always exist. Once it is destroyed, the timer is automatically stopped and deleted. Use the timer manager (menu scripts >> timer manager) to see a list of all active timer instances. This dialog also allows stopping or restarting these timers.

class itom.timer(interval, callbackFunc[, argTuple, singleShot]) → new callback timer

Creates a timer object that continuously calls a python callback function or method with a certain interval. The timer is active after construction and stops when this instance is destroyed or stop() is called.


interval : {int}

time out interval in ms

callbackFunc: {function, method} :

Python function that should be called when timer event raises

argTuple: {tuple}, optional :

tuple of parameters passed as arguments to the callback function

singleShot: {bool}, optional :

defines if this timer only fires one time after its start (True) or continuously (False, default)

isActive() → returns timer status

status : {bool}

True if the timer is running, otherwise False.

setInterval(interval) → sets timer interval in [ms]

This method sets the timeout interval in milliseconds. The timer calls the callback function continuously after this interval (if started)


interval : {int}

timeout interval in milliseconds. The callback function is continuously called after this timeout once the timer is started.

start() → starts timer

Starts or restarts the timer with its timeout interval. If the timer is already running, it will be stopped and restarted.

stop() → stops timer