pyudev.pyside – PySide integration¶
PySide integration.
QUDevMonitorObserver integrates device monitoring into the PySide
mainloop by turing device events into Qt signals.
PySide.QtCore from PySide must be available when importing this
module.
New in version 0.6.
-
class
pyudev.pyside.QUDevMonitorObserver(monitor, parent=None)¶ An observer for device events integrating into the
PySidemainloop.This class inherits
QObjectto turn device events into Qt signals:>>> from pyudev import Context, Monitor >>> from pyudev.pyqt4 import QUDevMonitorObserver >>> context = Context() >>> monitor = 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
QObject.-
__init__(monitor, parent=None)¶ Observe the given
monitor(aMonitor):parentis the parentQObjectof this object. It is passed unchanged to the inherited constructor ofQObject.
-
enabled¶ Whether this observer is enabled or not.
If
True(the default), this observer is enabled, and emits events. Otherwise it is disabled and does not emit any events. This merely reflects the state of theenabledproperty of the underlyingnotifier.New in version 0.14.
Signals
This class defines the following Qt signals:
-
deviceEvent(action, device)¶ Emitted upon any device event.
actionis a unicode string containing the action name, anddeviceis theDeviceobject describing the device.Basically the arguments of this signal are simply the return value of
receive_device()
-