QApplication case calling python shell sluggish

My IPython shell becomes sluggish after instantiating the QApplication object. For example, even from the very beginning, the following code will make my shell slow enough when I have to restart it.

from PyQt4 import QtGui
app = QtGui.QApplication([])

Once this is sent, my typing will be 2 or 3 seconds behind. My computer is not fantastic, but I still have a lot of memory available, and this is just a python shell that seems to be affected. I tried both the default python interpreter and the ipython interpreter with the same results. Any suggestions?

Update. I also tried running the standalone pyqt "Hello World" program in ipython using the %runmagic command , and when the control was returned to ipython after I closed the Hello World window that appeared, it had the same effect; the shell became lethargic, and my text input began for 2-3 seconds.

+5
source share
1 answer

This can help:

QtCore.pyqtRemoveInputHook()

When the QtCore module is imported for the first time, it sets Python (i.e., sets the Python value to the PyOS_InputHook variable). This allows you to enter commands in the interpreter when the application is running. Then you can dynamically create new Qt objects and call the methods of any existing Qt objects.

, , . , PyQt.

, pyqtRestoreInputHook() .

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

+3

All Articles