QUDevMonitorObserver plugs a pyudev.Monitor into the Qt event loop, so that Qt signals are asynchronously emitted upon events. This class is implemented for both available Qt bindings, PyQt4 and PySide.
Provide QUDevMonitorObserver to integrate a Monitor into the Qt event loop in applications using the PyQt4 binding to Qt.
To use this module, PyQt4.QtCore from PyQt4 must be available.
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 = pyudev.pyqt4.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.
Observe the given monitor (a Monitor):
parent is the parent QObject of this object. It is passed unchanged to the inherited constructor of QObject.
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 the enabled property of the underlying notifier.
New in version 0.14.
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()
Provide QUDevMonitorObserver to integrate a Monitor into the Qt event loop in applications using the PySide binding to Qt.
To use this module, PySide.QtCore from PySide must be available.
New in version 0.6.
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 = pyudev.pyqt4.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.
Observe the given monitor (a Monitor):
parent is the parent QObject of this object. It is passed unchanged to the inherited constructor of QObject.
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 the enabled property of the underlying notifier.
New in version 0.14.
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()
Provide GUDevMonitorObserver to integrate a Monitor into a glib.MainLoop.
To use this module, glib and gobject from PyGObject must be available. PyGtk is not required.
New in version 0.7.
Observe a Monitor and emit Glib signals upon device events:
>>> context = pyudev.Context()
>>> monitor = pyudev.Monitor.from_netlink(context)
>>> monitor.filter_by(subsystem='input')
>>> observer = pyudev.pygtk.GUDevMonitorObserver(monitor)
>>> def device_connected(observer, device):
... print('{0!r} added'.format(device))
>>> observer.connect('device-added', device_connected)
>>> monitor.start()
This class is a child of gobject.GObject.
The event source, which represents the watch on the monitor (as returned by glib.io_add_watch()), or None, if enabled is False.
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.
New in version 0.14.
Signals
This class defines the following GObject signals:
Emitted upon any device event. observer is the GUDevMonitorObserver, which emitted the signal. action is a unicode string containing the action name, and device is the Device, which caused this event.
Basically the last two arguments of this signal are simply the return value of receive_device()
Emitted if a Device is added (e.g a USB device was plugged).
Emitted if a Device is removed (e.g. a USB device was unplugged).
Emitted if a Device was somehow changed (e.g. a change of a property)
Emitted if a Device was renamed, moved or re-parented.
Provides WXUDevMonitorObserver to integrate a Monitor into a wx.App.MainLoop().
To use this module, wx from wxPython must be available.
New in version 0.14.
Observe a Monitor and post wx events upon device events:
>>> context = pyudev.Context()
>>> monitor = pyudev.Monitor.from_netlink(context)
>>> monitor.filter_by(subsystem='input')
>>> observer = pyudev.wx.WxUDevMonitorObserver(monitor)
>>> def device_connected(event):
... print('{0!r} added'.format(event.device))
>>> observer.Bind(EVT_DEVICE_ADDED, device_connected)
>>> monitor.start()
This class is a child of wx.EvtHandler.
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.
Event constants
WxUDevMonitorObserver exposes the following events:
Emitted upon any device event. Receivers get a DeviceEvent object as argument.
Emitted if a Device is added (e.g a USB device was plugged). Receivers get a DeviceAddedEvent object as argument.
Emitted if a Device is removed (e.g. a USB device was unplugged). Receivers get a DeviceRemovedEvent object as argument.
Emitted if a Device was somehow changed (e.g. a change of a property). Receivers get a DeviceChangedEvent object as argument.
Emitted if a Device was renamed, moved or re-parented. Receivers get a DeviceMovedEvent object as argument.
Event objects
Argument object for EVT_DEVICE_EVENT.
A unicode string containing the action name.
Argument objects for EVT_DEVICE_ADDED, EVT_DEVICE_REMOVED, EVT_DEVICE_CHANGED and EVT_DEVICE_MOVED.