To plug monitoring with pyudev.Monitor into the Qt event loop, so that Qt signals are asynchronously emitted upon events, QUDevMonitorObserver is provided:
Observe a Monitor and emit Qt signals upon device events:
>>> context = pyudev.Context()
>>> monitor = pyudev.Monitor.from_netlink(context)
>>> monitor.filter_by(subsystem='input')
>>> observer = QUDevMonitorObserver(monitor)
>>> def device_connected(device):
... print('{0!r} added'.format(device))
>>> observer.deviceAdded.connect(device_connected)
>>> monitor.start()
This class is a child of QtCore.QObject.
Observe the given monitor (a pyudev.Monitor).
parent is the parent QObject of this object. It is passed straight to the inherited constructor of QObject.
Signals
This class defines the following Qt signals:
Emitted upon any device event. action is a unicode string containing the action name, and device is the Device object describing the device.
Basically the arguments of this signal are simply the return value of receive_device()
Currently there are two different, incompatible bindings to Qt4:
For both of these bindings a QUDevMonitorObserver implementation is provided, each in a separate module:
A QUDevMonitorObserver implementation for PyQt4_
A QUDevMonitorObserver implementation for PySide_