pyudev.wx – wxPython integration¶
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.
-
class
pyudev.wx.WxUDevMonitorObserver(monitor)¶ An observer for device events integrating into the
wxmainloop.This class inherits
EvtHandlerto 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.-
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.
-
Event constants
WxUDevMonitorObserver exposes the following events:
-
pyudev.wx.EVT_DEVICE_EVENT¶ Emitted upon any device event. Receivers get a
DeviceEventobject as argument.
-
pyudev.wx.EVT_DEVICE_ADDED¶ Emitted if a
Deviceis added (e.g a USB device was plugged). Receivers get aDeviceAddedEventobject as argument.
-
pyudev.wx.EVT_DEVICE_REMOVED¶ Emitted if a
Deviceis removed (e.g. a USB device was unplugged). Receivers get aDeviceRemovedEventobject as argument.
-
pyudev.wx.EVT_DEVICE_CHANGED¶ Emitted if a
Devicewas somehow changed (e.g. a change of a property). Receivers get aDeviceChangedEventobject as argument.
-
pyudev.wx.EVT_DEVICE_MOVED¶ Emitted if a
Devicewas renamed, moved or re-parented. Receivers get aDeviceMovedEventobject as argument.
Event objects
-
class
pyudev.wx.DeviceEvent¶ Argument object for
EVT_DEVICE_EVENT.-
action¶ A unicode string containing the action name.
-
-
class
pyudev.wx.DeviceAddedEvent¶ -
class
pyudev.wx.DeviceRemovedEvent¶ -
class
pyudev.wx.DeviceChangedEvent¶ -
class
pyudev.wx.DeviceMovedEvent¶ Argument objects for
EVT_DEVICE_ADDED,EVT_DEVICE_REMOVED,EVT_DEVICE_CHANGEDandEVT_DEVICE_MOVED.