gpt4 book ai didi

python - 如何在向后兼容的代码中使用 GLib.io_add_watch ?

转载 作者:太空宇宙 更新时间:2023-11-04 04:03:45 25 4
gpt4 key购买 nike

在 Ubuntu 14.04 下运行一些较旧的 Python+GTK3 代码时,出现以下弃用警告:

PyGIDeprecationWarning: io_add_watch is deprecated; use GLib.io_add_watch instead
/usr/lib/python3/dist-packages/gi/overrides/GLib.py:655: PyGIDeprecationWarning: Calling io_add_watch without priority as second argument is deprecated
/usr/lib/python3/dist-packages/gi/overrides/GLib.py:666: PyGIDeprecationWarning: Calling io_add_watch with priority keyword argument is deprecated, put it as second positional argument

这来自调用 GObject.io_add_watch() 的行。

来自http://www.piware.de/2012/11/pygobject-3-7-2-released/http://lazka.github.io/pgi-docs/api/GLib_2.0/functions.html?highlight=add_watch#GLib.io_add_watch看起来 GLib.io_add_watch() 的参数配置文件与 GObject.io_add_watch() 不同。所以现在我想知道:

  1. 在 Python+GTK3 中设置 fd 上的 I/O 监视的正确方法是什么?使用哪个函数,使用什么参数配置文件?
  2. 我怎样才能以与旧系统兼容的方式编写代码,例如。 Ubuntu 12.04?

任何在新旧系统中使用此 API 的经验都可以提供一些提示吗?

最佳答案

GLib.io_add_watch() 已经存在很长时间了:早在 Ubuntu 12.04 发布之前它就已经存在了。所以正确的做法是使用它。

我认为函数签名非常相似,除了优先级之外:您可能应该使用 GLib.PRIORITY_DEFAULT。

关于python - 如何在向后兼容的代码中使用 GLib.io_add_watch ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22081343/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com