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