gpt4 book ai didi

python - 运行时警告 : PyOS_InputHook is not available for interactive use of PyGTK

转载 作者:行者123 更新时间:2023-11-28 17:33:20 26 4
gpt4 key购买 nike

我在 Ubuntu 14.04 中使用适用于 Python 2.7 的 PyGTK,但我收到以下消息:

RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK

可能是什么原因?

最佳答案

什么时候触发?您是在尝试运行一些脚本还是仅以交互方式使用 PyGTK?

很可能,您的输入 Hook 被另一个交互式循环捕获,例如:

>>> import Tkinter
>>> root = Tkinter.Tk() # input hook is grabbed by Tkinter for immediate result evaluation
>>> import gtk # gtk tries to grab the hook, but fails
/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:127: RuntimeWarning: PyOS_InputHook is not available for interactive use of PyGTK

立即结果评估 表示在进入主循环之前立即评估表达式结果(例如显示窗口)。

请记住,这是一个警告,而不是一个错误,但如果它困扰你,您可以尽早导入 gtk 模块(或者,好吧,相当早)并释放输入 Hook :

import gtk
gtk.set_interactive(False)
import Tkinter
root = Tkinter.Tk()
# no warning here

关于python - 运行时警告 : PyOS_InputHook is not available for interactive use of PyGTK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32754630/

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