Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

How to call subprocess in pyside2 wizard?



  • I want to add the snap install --dangerous example.snap to this code

    #How to do it
    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 snap installer offline")
        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)
        self.coba()
    
    
    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.ClassicStyle)
    wizard.show()
    
    sys.exit(app.exec_())

Log in to reply