Migration from dbus to GDbus in Python 3

泪湿孤枕 提交于 2020-03-03 08:10:10

问题


I have tried to write a service file in python using GDbus. But I could not find a good tutorial, only if i want to use C. Since I want to include GDbus in an existing Python code i have no idea how to do that.

It was possible for me to write a service file using dbus and I could access that service file with a GDbus client.

I would be very happy if somebody had a good example in Python. Thanks a lot, Dominik


回答1:


While you can use GDBus from Python, it might not be the nicest (most Pythonic) API to use, since it’s a C API which is mechanically introspected and exposed to Python.

You might be better off using pydbus, which is a modern D-Bus client library written for Python. Its documentation has plenty of examples in Python.

If you must use GDBus, here are some Python examples:

  • https://wiki.gnome.org/HowDoI/GDBusPython
  • https://github.com/hexchat/hexchat/blob/master/src/common/dbus/example.py

And here’s the GDBus API reference for Python (mechanically generated from the C API):

  • https://lazka.github.io/pgi-docs/Gio-2.0/classes/DBusProxy.html


来源:https://stackoverflow.com/questions/54113389/migration-from-dbus-to-gdbus-in-python-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!