QApplication实例导致python shell缓慢

QApplication实例导致python shell缓慢,第1张

概述在我实例化QApplication对象后,我的I Python shell变得迟缓.例如,即使从一个新的开始,以下代码将使我的shell缓慢到必须重新启动它. from PyQt4 import QtGuiapp = QtGui.QApplication([]) 一旦提交,我的输入就会滞后2或3秒.我的计算机并不太棒,但我仍然有足够的可用内存,而且它只是受到影响的python shell.我已经 在我实例化QApplication对象后,我的I Python shell变得迟缓.例如,即使从一个新的开始,以下代码将使我的shell缓慢到必须重新启动它.
from PyQt4 import QtGuiapp = QtGui.QApplication([])

一旦提交,我的输入就会滞后2或3秒.我的计算机并不太棒,但我仍然有足够的可用内存,而且它只是受到影响的python shell.我已经尝试了默认的python解释器和ipython解释器,但结果相同.有什么建议?

更新:我还尝试使用%run magic命令在ipython中运行一个独立的pyqt“Hello World”程序,当我关闭生成的“Hello World”窗口后,当控件返回到ipython时,它具有相同的效果;外壳变得迟钝,我的打字开始滞后2-3秒.

解决方法 这可能有所帮助:
QtCore.pyqtRemoveinputHook()

When the QtCore module is imported for the first time it installs a
Python input hook (IE. it sets the value of Python’s PyOS_inputHook
variable). This allows commands to be entered at the interpreter
prompt while the application is running. It is then possible to
dynamically create new Qt objects and call the methods of any existing
Qt object.

The input hook can cause problems for certain types of application,
particularly those that provIDe a similar facility through different
means. This function removes the input hook installed by PyQt.

The input hook can be restored using the pyqtRestoreinputHook()
function.

http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qtcore.html#pyqtRemoveInputHook

总结

以上是内存溢出为你收集整理的QApplication实例导致python shell缓慢全部内容,希望文章能够帮你解决QApplication实例导致python shell缓慢所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/1205155.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-04
下一篇2022-06-04

发表评论

登录后才能评论

评论列表(0条)

    保存