I am trying to change my code from PyQt5 to PySide2. Most of the my scripts I simply have to change imports from PyQt5 to PySide2 and it works the same. However I tried to rework the licensewizard example in the Qt documentation from PyQt5 to PySide2. In PyQt5 it works perfectly, However, in PySide2 I get a error with exit code 139 (interrupted by signal 11: SIGSEGV). The PySide2 qwizard code for linear wizards like the class wizard example, works fine. Does anyone knows why it fails with the non linear wizards and why I get that error?
Thanks
The code below works for PyQt5. Replacing PyQt5 with PySide2 I get an error
Process finished with exit code 132 (interrupted by signal 4: SIGILL)
class IntroductionPage(QtWidgets.QWizardPage):
def __init__(self):
super(IntroductionPage, self).__init__()
self.setTitle("Introduction")
self.label = QtWidgets.QLabel("set this up")
self.label.setWordWrap(True)
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.label)
self.setLayout(self.layout)
def nextId(self):
return Wizard.class1
class ClassesPage1(QtWidgets.QWizardPage):
def __init__(self):
super(ClassesPage1, self).__init__()
self.setTitle("Choices")
self.setSubTitle("Choose 1")
self.radButton1 = QtWidgets.QRadioButton('1A')
self.radButton2 = QtWidgets.QRadioButton('1B')
self.radButton3 = QtWidgets.QRadioButton('1C')
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.radButton1)
self.layout.addWidget(self.radButton2)
self.layout.addWidget(self.radButton3)
self.class_selected1 = QtWidgets.QLineEdit()
self.setLayout(self.layout)
def nextId(self):
if self.radButton2.isChecked():
return Wizard.class2
elif self.radButton3.isChecked():
return Wizard.class2
else:
return Wizard.conclusion
class ClassesPage2(QtWidgets.QWizardPage):
def __init__(self):
super(ClassesPage2, self).__init__()
#self.page = QWizardPage()
self.setTitle("Classes for grade 2")
self.setSubTitle("Please select a Class")
self.radButton1 = QtWidgets.QRadioButton('2A')
self.radButton2 = QtWidgets.QRadioButton('2B')
self.radButton3 = QtWidgets.QRadioButton('2C')
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.radButton1)
self.layout.addWidget(self.radButton2)
self.layout.addWidget(self.radButton3)
self.class_selected2 = QtWidgets.QLineEdit()
self.setLayout(self.layout)
def nextId(self):
return Wizard.conclusion
class ClassesPage3(QtWidgets.QWizardPage):
def __init__(self):
super(ClassesPage3, self).__init__()
self.setTitle("Classes for grade 3")
self.setSubTitle("Please select a Class")
self.radButton1 = QtWidgets.QRadioButton('3A')
self.radButton2 = QtWidgets.QRadioButton('3B')
self.radButton3 = QtWidgets.QRadioButton('3C')
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.radButton1)
self.layout.addWidget(self.radButton2)
self.layout.addWidget(self.radButton3)
self.class_selected3 = QtWidgets.QLineEdit()
self.setLayout(self.layout)
def nextId(self):
return Wizard.conclusion
class ConclusionPage(QtWidgets.QWizardPage):
def __init__(self):
super(ConclusionPage, self).__init__()
self.layout = QtWidgets.QVBoxLayout()
self.label = QtWidgets.QLabel(self)
self.label2 = QtWidgets.QLabel(self)
self.layout.addWidget(self.label)
self.layout.addWidget(self.label2)
self.setLayout(self.layout)
class Wizard(QtWidgets.QWizard):
num_of_pages = 5
(intro, class1, class2, class3, conclusion) = range(num_of_pages)
def __init__(self):
super(Wizard, self).__init__()
self.setPage(self.intro, IntroductionPage())
self.setPage(self.class1, ClassesPage1())
self.setPage(self.class2, ClassesPage2())
self.setPage(self.class3, ClassesPage3())
self.setPage(self.conclusion, ConclusionPage())
self.setStartId(self.intro)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
wizard = Wizard()
wizard.setWindowTitle("Set Up")
wizard.setWizardStyle(QtWidgets.QWizard.MacStyle)
wizard.show()
sys.exit(app.exec_())
It seems that unlike PyQt5, PySide2 requires that you pass a parent, in your case the solution is to change the constructors of the classes:
class Some_Page(QtWidgets.QWizardPage):
def __init__(self):
super(Some_Page, self).__init__()
to:
class Some_Page(QtWidgets.QWizardPage):
def __init__(self, *args, **kwargs):
super(Some_Page, self).__init__(*args, **kwargs)
When we add a page, we pass the parent to him:
class Wizard(QtWidgets.QWizard):
num_of_pages = 5
(intro, class1, class2, class3, conclusion) = range(num_of_pages)
def __init__(self, *args, **kwargs):
super(Wizard, self).__init__(*args, **kwargs)
self.setPage(self.intro, IntroductionPage(self))
self.setPage(self.class1, ClassesPage1(self))
self.setPage(self.class2, ClassesPage2(self))
self.setPage(self.class3, ClassesPage3(self))
self.setPage(self.conclusion, ConclusionPage(self))
self.setStartId(self.intro)
Complete Code:
from PySide2 import QtWidgets
import sys
class IntroductionPage(QtWidgets.QWizardPage):
def __init__(self, *args, **kwargs):
super(IntroductionPage, self).__init__(*args, **kwargs)
self.setTitle("Introduction")
self.label = QtWidgets.QLabel("Welcome to the One Incâ„¢'s Teacher Interactive Accessment tool. Follow the prompts to set up your Mark Sheet")
self.label.setWordWrap(True)
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.label)
self.setLayout(self.layout)
def nextId(self):
return Wizard.class1
class ClassesPage1(QtWidgets.QWizardPage):
def __init__(self, *args, **kwargs):
super(ClassesPage1, self).__init__(*args, **kwargs)
self.setTitle("Choices")
self.setSubTitle("Choose 1")
self.radButton1 = QtWidgets.QRadioButton('1A')
self.radButton2 = QtWidgets.QRadioButton('1B')
self.radButton3 = QtWidgets.QRadioButton('1C')
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.radButton1)
self.layout.addWidget(self.radButton2)
self.layout.addWidget(self.radButton3)
self.setLayout(self.layout)
def nextId(self):
if self.radButton2.isChecked():
return Wizard.class2
elif self.radButton3.isChecked():
return Wizard.class2
else:
return Wizard.conclusion
class ClassesPage2(QtWidgets.QWizardPage):
def __init__(self, *args, **kwargs):
super(ClassesPage2, self).__init__(*args, **kwargs)
#self.page = QWizardPage()
self.setTitle("Classes for grade 2")
self.setSubTitle("Please select a Class")
self.radButton1 = QtWidgets.QRadioButton('2A')
self.radButton2 = QtWidgets.QRadioButton('2B')
self.radButton3 = QtWidgets.QRadioButton('2C')
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.radButton1)
self.layout.addWidget(self.radButton2)
self.layout.addWidget(self.radButton3)
self.class_selected2 = QtWidgets.QLineEdit()
self.setLayout(self.layout)
def nextId(self):
return Wizard.conclusion
class ClassesPage3(QtWidgets.QWizardPage):
def __init__(self, *args, **kwargs):
super(ClassesPage3, self).__init__(*args, **kwargs)
self.setTitle("Classes for grade 3")
self.setSubTitle("Please select a Class")
self.radButton1 = QtWidgets.QRadioButton('3A', self)
self.radButton2 = QtWidgets.QRadioButton('3B', self)
self.radButton3 = QtWidgets.QRadioButton('3C', self)
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(self.radButton1)
self.layout.addWidget(self.radButton2)
self.layout.addWidget(self.radButton3)
self.class_selected3 = QtWidgets.QLineEdit()
self.setLayout(self.layout)
def nextId(self):
return Wizard.conclusion
class ConclusionPage(QtWidgets.QWizardPage):
def __init__(self, *args, **kwargs):
super(ConclusionPage, self).__init__(*args, **kwargs)
self.layout = QtWidgets.QVBoxLayout()
self.label = QtWidgets.QLabel(self)
self.label2 = QtWidgets.QLabel(self)
self.layout.addWidget(self.label)
self.layout.addWidget(self.label2)
self.setLayout(self.layout)
class Wizard(QtWidgets.QWizard):
num_of_pages = 5
(intro, class1, class2, class3, conclusion) = range(num_of_pages)
def __init__(self, *args, **kwargs):
super(Wizard, self).__init__(*args, **kwargs)
self.setPage(self.intro, IntroductionPage(self))
self.setPage(self.class1, ClassesPage1(self))
self.setPage(self.class2, ClassesPage2(self))
self.setPage(self.class3, ClassesPage3(self))
self.setPage(self.conclusion, ConclusionPage(self))
self.setStartId(self.intro)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
wizard = Wizard()
wizard.setWindowTitle("Set Up")
wizard.setWizardStyle(QtWidgets.QWizard.MacStyle)
wizard.show()
sys.exit(app.exec_())