Wx integration.
WxUDevMonitorObserver 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.
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, Device
>>> from pyudev.wx import WxUDevMonitorObserver
>>> context = Context()
>>> monitor = Monitor.from_netlink(context)
>>> monitor.filter_by(subsystem='input')
>>> observer = 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.