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._ObserverMixin

An observer for device events integrating into the glib mainloop.

Deprecated since version 0.17: Will be removed in 1.0. Use MonitorObserver instead.

class pyudev.glib.MonitorObserver(monitor)

Bases: Mock, pyudev.glib._ObserverMixin

An observer for device events integrating into the glib mainloop.

This class inherits GObject to 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.