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

Vincent Vande Vyvre vincent.vande.vyvre at telenet.be
Thu Sep 24 23:21:51 BST 2015


Le 25/09/2015 00:08, Reinder Feenstra a écrit :
> 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
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt


Maybe because when python exit the function create_and_show_dialog() the 
dialog is garbage-collected ?

Vincent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150925/e157ad26/attachment.html>


More information about the PyQt mailing list