The interrupt module contains the InterruptThread class which provides a Thread which will periodically notify a QWidget.
The Interruptable class provides an interface for interrupting a class at a specific interval.
This class created an InterruptThread object which notifies the interrupt() function at the specified period.
Example:
class Example(Interruptable):
def __init__(self):
Interruptable.__init__(self, period=1)
# This function is called once per second, and i is the current
# iteration number.
def interrupt(self, i):
print i
Override the interrupt function. This function is called once per cycle of the InterruptThread.
Note
This function should be overridden by subclasses.
The InterruptThread class implements a PyQt4.Qt.QThread to call the interrupt function of a given object at a specifiable rate.
The InterruptThread class can define the period property to determine the number of seconds the PyQt4.Qt.QThread will sleep during each iteration. The default period is 0.1 seconds.
This class throws an amp.exceptions.UndefinedFunctionError in the event that the interrupt function is not defined by the parent object.
Note
The interrupt function takes one parameter which is the current interation number that the interrupt thread is on. The iteration number increases once per cycle.
Example:
class Example():
def __init__(self):
self.__interrupt = InterruptThread(self, period=0.5)
self.__interrupt.start()
def interrupt(self, i):
print i
Note
The parent object must have a function named interrupt defined.
Definine the number of seconds the PyQt4.Qt.QThread will sleep between each cycle, prior to interrupting the parent object.