The interrupt module

The interrupt module contains the InterruptThread class which provides a Thread which will periodically notify a QWidget.

The Interruptable class

Inheritance diagram of pyamp.ui.qt.interrupt.Interruptable

class pyamp.ui.qt.interrupt.Interruptable(period=0.10000000000000001)[source]

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
  • period – The number of seconds to sleep during each cycle
interrupt(_i)[source]

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

Inheritance diagram of pyamp.ui.qt.interrupt.InterruptThread

class pyamp.ui.qt.interrupt.InterruptThread(parent, period=None)[source]

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
  • parent – The parent of this thread.
  • period – The number of seconds to sleep between each interrupt

Note

The parent object must have a function named interrupt defined.

period

Definine the number of seconds the PyQt4.Qt.QThread will sleep between each cycle, prior to interrupting the parent object.

run()[source]

Run the interrupt thread.

Table Of Contents

Previous topic

The baseWidget module

Next topic

The keyEvents module

This Page