pyudev.pyqt4
– PyQt4 integration¶
PyQt4 integration.
MonitorObserver
integrates device monitoring into the PyQt4_
mainloop by turning device events into Qt signals.
PyQt4.QtCore
from PyQt4_ must be available when importing this
module.
-
class
pyudev.pyqt4.
MonitorObserver
(monitor, parent=None)¶ An observer for device events integrating into the
PyQt4
mainloop.This class inherits
QObject
to turn device events into Qt signals:>>> from pyudev import Context, Monitor >>> from pyudev.pyqt4 import MonitorObserver >>> context = Context() >>> monitor = Monitor.from_netlink(context) >>> monitor.filter_by(subsystem='input') >>> observer = MonitorObserver(monitor) >>> def device_event(device): ... print('event {0} on device {1}'.format(device.action, device)) >>> observer.deviceEvent.connect(device_event) >>> monitor.start()
This class is a child of
QObject
.-
__init__
(monitor, parent=None)¶ Observe the given
monitor
(aMonitor
):parent
is the parentQObject
of 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 theenabled
property of the underlyingnotifier
.New in version 0.14.
Signals
This class emits the following Qt signal:
-
Deprecated API¶
-
class
pyudev.pyqt4.
QUDevMonitorObserver
(monitor, parent=None)¶ An observer for device events integrating into the
PyQt4
mainloop.Deprecated since version 0.17: Will be removed in 1.0. Use
MonitorObserver
instead.-
__init__
(monitor, parent=None)¶ Observe the given
monitor
(aMonitor
):parent
is the parentQObject
of 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 theenabled
property of the underlyingnotifier
.New in version 0.14.
Signals
This class emits the following Qt signals:
-
deviceEvent
(action, device)¶ Emitted upon any device event.
action
is a unicode string containing the action name, anddevice
is theDevice
object describing the device.Basically the arguments of this signal are simply the return value of
receive_device()
-