[PyQt] Creating and showing dialog in other unit seems not to work

Reinder Feenstra reinderfeenstra at gmail.com
Thu Sep 24 23:08:44 BST 2015


Dear Readers,

I've an issue with creating dialogs in an other file than the QApplication,
I created two tests to show the problem:

== dialog_test_1.py
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *

app = QApplication(sys.argv)

dialog = QDialog()
dialog.show()

sys.exit(app.exec_())

== dialog_test_2.py
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import dialog_test_2_utils

app = QApplication(sys.argv)

dialog_test_2_utils.create_and_show_dialog()

sys.exit(app.exec_())

== dialog_test_2_utils.py
from PyQt4.QtCore import *
from PyQt4.QtGui import *

def create_and_show_dialog():
    dialog = QDialog()
    dialog.show()

dialog_test_1 works as expected
dialog_test_2 doesn't show the dialog, why?

I don't understand why it makes a difference when the dialog is created and
shown in another file.

System info:
OS: Kubuntu 15.04 (amd64)
Python: 2.7.9
PyQt4: 4.10.4

Best regards,
Reinder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150925/abb53378/attachment.html>


More information about the PyQt mailing list