0

Trying to open 2 windows using PyQt5 we experienced a brutal python exit with segmentation error message.

The minimal reproducing error is:

Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5 import QtCore, QtGui, QtWidgets
>>> def application():
...     import sys
...     app = QtWidgets.QApplication(sys.argv)
...     Dialog = QtWidgets.QDialog()
...     Dialog.show()
...     app.exec_()
... 
>>> import sys
>>> app = QtWidgets.QApplication(sys.argv)
>>> MainWindow = QtWidgets.QMainWindow()
>>> list = application()
>>> MainWindow.show()
Segmentation error (core dumped)

We suspect that the first window hamper the second window opening. How can we open the two windows without problem ?

1
  • Why are you creating two QApplication objects? Commented Apr 7, 2017 at 5:46

1 Answer 1

1

You're right, it's because I've created 2 QApplication objects that I have a problem. Also this program works with this code:

from PyQt5 import QtCore, QtGui, QtWidgets

def application():
    import sys
    Dialog = QtWidgets.QDialog()
    Dialog.show()
    app.exec_()


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    list = application()
    MainWindow.show()
    sys.exit(app.exec_())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.