[PyQt] with PyQt's input hook, is it expected that sending to stdin dismisses a modal dialog created in response to a signal?

Phil Thompson phil at riverbankcomputing.com
Tue Feb 23 19:29:40 GMT 2016


> On 23 Feb 2016, at 3:17 pm, Erik Hvatum <ice.rikh at gmail.com> wrote:
> 
> With PyQt's input hook, is it expected that sending \n to stdin dismisses a modal dialog created in response to a signal?  Looking at qtcore_input_hook() in qcoreapplication.sip, it's easy to see why this happens, and it seems like a reasonable compromise between permitting modal dialogs and avoiding blocking the Python prompt.  Still, google doesn't reveal a definitive answer, and I'd like to be sure that I understand the situation.
> 
> On OS X:
> 
> > python3
> Python 3.5.1 (default, Dec 14 2015, 16:26:43) 
> [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from PyQt5 import Qt
> >>> import sys
> >>> app = Qt.QApplication(sys.argv)
> >>> def show_file_dlg():
> ...     Qt.QFileDialog.getSaveFileName(None, 'test',filter='tests (*.test *.tst)')
> ... 
> >>> t = Qt.QTimer()
> >>> t.setSingleShot(True)
> >>> t.timeout.connect(show_file_dlg)
> >>> t.start(1000) # wait a second, file dialog appears
> >>> # press enter in terminal, file dialog is dismissed and we get a new prompt
> >>> 
> 
> The behavior on Linux is the same.

I don't think it was specifically designed to do that - just that's what happens to happen.

Phil


More information about the PyQt mailing list