pyudev.wx module

Wx integration.

MonitorObserver integrates device monitoring into the wxPython_ mainloop by turing device events into wx events.

wx from wxPython_ must be available when importing this module.

New in version 0.14.

class pyudev.wx.MonitorObserver(monitor)

Bases: Mock

An observer for device events integrating into the wx mainloop.

This class inherits EvtHandler to turn device events into wx events:

>>> from pyudev import Context, Monitor
>>> from pyudev.wx import MonitorObserver
>>> context = Context()
>>> monitor = Monitor.from_netlink(context)
>>> monitor.filter_by(subsystem='input')
>>> observer = MonitorObserver(monitor)
>>> def device_event(event):
...     print('action {0} on device {1}'.format(event.device.action, event.device))
>>> observer.Bind(EVT_DEVICE_EVENT, device_event)
>>> monitor.start()

This class is a child of wx.EvtHandler.

New in version 0.17.

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

start()

Enable this observer.

Do nothing, if the observer is already enabled.

stop()

Disable this observer.

Do nothing, if the observer is already disabled.

pyudev.wx.NewEvent()
class pyudev.wx.WxUDevMonitorObserver(monitor)

Bases: pyudev.wx.MonitorObserver

An observer for device events integrating into the wx mainloop.

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