您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

QApplication实例导致python shell缓慢

5b51 2022/1/14 8:20:30 python 字数 2116 阅读 459 来源 www.jb51.cc/python

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

概述

from PyQt4 import QtGui
app = 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缓慢所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶