[英]udev interface for python3?
有没有关于如何在 Python3 中捕获udev
事件的示例? 我无法让事件在.237(或 1.0?)中工作。 并且无法通过 Introspection 获得任何GUdev 示例。
我不确定问题出在哪里。 我找到了一个示例test.py
但在那里,在实例化Client
时给出了参数,例如client = GUdev.Client(['block'])
。 实际版本中不接受这些参数( TypeError: GObject.__init__() takes exactly 0 arguments (1 given)
)。
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('GUdev', '1.0')
from gi.repository import Gtk, GUdev, GLib
def on_uevent(client, action, device):
print(action)
client = GUdev.Client()
client.connect('uevent', on_uevent)
GLib.MainLoop().run()
呃,好吧。 似乎 G(NU|nome|object)-Introspection 在其工作中改变了一些东西。
...
client = GUdev.Client.new(['block'])
client.connect('uevent', on_uevent)
...
工作正常。 我不知道为什么旧语法(见上文)不会抛出任何错误......
顺便说一句, GUdev.Client.new(['block'])
接受列表中的多个值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.