加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

QApplication实例导致python shell缓慢

发布时间:2020-12-16 21:41:34 所属栏目:Python 来源:网络整理
导读:在我实例化QApplication对象后,我的I Python shell变得迟缓.例如,即使从一个新的开始,以下代码将使我的shell缓慢到必须重新启动它. from PyQt4 import QtGuiapp = QtGui.QApplication([]) 一旦提交,我的输入就会滞后2或3秒.我的计算机并不太棒,但我仍然有足
在我实例化QApplication对象后,我的I Python shell变得迟缓.例如,即使从一个新的开始,以下代码将使我的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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读