[PyQt] Strange bug with QFileDialog static methods and IPython running in a QProcess on win32

Pierre Raybaut pierre.raybaut at gmail.com
Sun Jun 20 09:26:44 BST 2010

Hi Phil,

I did a lot of tests about this bug and I still can't understand where it
comes from.
At least I've succeeded in narrowing down the test cases:

* test #1:

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

filename = QFileDialog.getSaveFileName(None)

* test #2:

from PyQt4.QtGui import QFileDialog, QPushButton, QApplication

from PyQt4.QtCore import SIGNAL

app = QApplication([])

button = QPushButton("Test", None)

button.connect(button, SIGNAL("clicked()"),

lambda: QFileDialog.getSaveFileName(None))



I'm running these tests in Spyder's external console: this is a console
widget (QPlainTextEdit) showing stdin, stdout and stderr of a Python or
IPython interpreter running in a QProcess (see this screenshot:
Running test #1 is a success in every situation (simple Python interpreter
or IPython running).
On the contrary, running test #2 gives the following results:
    * simple Python interpreter: ok
    * IPython: the GUI freezes when clicking the button, and it unfreezes
when sending something in QProcess' stdin (like pressing <ENTER> in the

Apparently the only difference between these two tests is that I'm running
QApplication's event loop in test #2.
But note that this freezing situation is only happening for QFileDialog's
static methods (getOpenFileName, getSaveFileName, and so on) and is never
happening for other kinds of widgets or dialog boxes... and I remember
seeing a message in stdout when using these methods in PyQt v4.3 (something
like "redirecting in win32 console") suggesting that these methods were
doing weird things on stdin/stdout and that it could be related to this bug.

I'm stuck with this bug, so I would really appreciate your help!
Note that it's excellent news to be able to embed IPython in a PyQt-based
IDE: this will be the first time an IDE is able to provide such powerful
feature... so this is also great news for PyQt!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100620/dc58a8a7/attachment.html>

More information about the PyQt mailing list