pyudev.glib module¶
Glib integration.
MonitorObserver integrates device monitoring into the Glib
mainloop by turing device events into Glib signals.
glib and gobject from PyGObject must be available when
importing this module. PyGtk is not required.
New in version 0.7.
-
class
pyudev.glib.GUDevMonitorObserver(monitor)¶ Bases:
Mock,pyudev.glib._ObserverMixinAn observer for device events integrating into the
glibmainloop.Deprecated since version 0.17: Will be removed in 1.0. Use
MonitorObserverinstead.
-
class
pyudev.glib.MonitorObserver(monitor)¶ Bases:
Mock,pyudev.glib._ObserverMixinAn observer for device events integrating into the
glibmainloop.This class inherits
GObjectto turn device events into glib signals.>>> from pyudev import Context, Monitor >>> from pyudev.glib import MonitorObserver >>> context = Context() >>> monitor = Monitor.from_netlink(context) >>> monitor.filter_by(subsystem='input') >>> observer = MonitorObserver(monitor) >>> def device_event(observer, device): ... print('event {0} on device {1}'.format(device.action, device)) >>> observer.connect('device-event', device_event) >>> monitor.start()
This class is a child of
gobject.GObject.