Beispiel #1
0
class ReadyPage(QWizardPage):
    def __init__(self, title="Ready", sub_title=" "):
        QWizardPage.__init__(self)
        self.setTitle(title)
        self.setSubTitle(sub_title)
        self.setCommitPage(True)
        self.createWidgets()
        self.setButtonText(QWizard.CommitButton, "Start")

    def createWidgets(self):
        vlayout = QVBoxLayout()
        vlayout.addWidget(
            QLabel(
                "PST now has all information necessary to start the analysis.")
        )
        vlayout.addStretch(1)
        self._propView = QPlainTextEdit()
        self._propView.setReadOnly(True)
        self._propView.setVisible(False)
        vlayout.addWidget(self._propView, 30)
        hlayout = QHBoxLayout()
        hlayout.addWidget(QLabel("Click 'Start' to start the analysis."), 1)
        self._toggleSettingsButton = QPushButton("Show settings")
        self._toggleSettingsButton.clicked.connect(self.onToggleShowSettings)
        hlayout.addWidget(self._toggleSettingsButton)
        vlayout.addLayout(hlayout)
        self.setLayout(vlayout)

    def initializePage(self):
        self.wizard().removeDeprecatedProperties()
        props = self.wizard().properties()
        text = json.dumps(props,
                          sort_keys=True,
                          indent=4,
                          separators=(',', ': '))
        self._propView.setPlainText(text)

    def validatePage(self):
        if not QWizardPage.validatePage(self):
            return False
        self.wizard().saveProperties()
        return True

    def onToggleShowSettings(self):
        visible = not self._propView.isVisible()
        self._propView.setVisible(visible)
        self._toggleSettingsButton.setText(
            "Hide settings" if visible else "Show settings")