title: After QPushButton clicked execute some code and when finished automatically go to next QWizardPage
body: <p>I have a wizard with three pages. First page is <code>BasicSettings()</code>, second page is <code>InstallPackages()</code> and the last page (finish) is <code>Summary()</code>. <code>BasicSettings()</code> is for creating a virtual environment. If the <em>'Install and update Pip'</em> checkbox is left unchecked, the wizard should go directly to the last page <code>Summary()</code>, else it should go on to <code>InstallPackages()</code> where the user can install some packages into the created virtual environment. And the last step is from there to go to <code>Summary()</code> where there is the 'finish' button.</p>
  
  <p>In the code example below the <code>createButton</code> is connected to the method <code>execute_venv_create()</code>. When the method has executed the code, a message box pops up, indicating that the process has finished. </p>
  
  <p>Now, when the user clicks <kbd>Ok</kbd> I want the wizard to automatically go to the next page defined by <code>QWizard().nextId</code>. I thought that I could achieve that by invoking <code>QWizard().next()</code>, but that doesen't work. I tried connecting <code>createButton</code> to it, but that doesn't have an effect. </p>
  
  <p>How can I make the wizard automatically go on to the next page after <code>execute_venv_create()</code> finished executing code and the user has confirmed the info message box?</p>
  
  <hr>
  
  <p><strong>Code to reproduce:</strong></p>
  
  <pre class="lang-python prettyprint-override"><code># -*- coding: utf-8 -*-
  from PyQt5.QtGui import QIcon
  from PyQt5.QtCore import Qt
  from PyQt5.QtWidgets import (QApplication, QGridLayout, QLabel, QCheckBox,
                               QHBoxLayout, QVBoxLayout, QToolButton, QWizard,
                               QWizardPage, QComboBox, QTableView, QLineEdit,
                               QGroupBox, QPushButton, QMessageBox)
  
  
  class VenvWizard(QWizard):
      """
      Wizard for creating and setting up a virtual environment.
      """
      def __init__(self):
          super().__init__()
  
          self.setWindowTitle("Venv Wizard")
          self.resize(635, 480)
          self.move(528, 153)
  
          basicSettings = BasicSettings()
          self.addPage(basicSettings)
  
          installId = self.addPage(InstallPackages())
          summaryId = self.addPage(Summary())
  
          # go to last page if pip wasn't selected else go to the install page
          basicSettings.nextId = (
              lambda: installId if basicSettings.withPipCBox.isChecked()
              else summaryId
          )
  
          # ...
  </code></pre>
  
  <hr>
  
  <pre class="lang-python prettyprint-override"><code>class BasicSettings(QWizardPage):
      """
      Basic settings of the virtual environment to create.
      """
      def __init__(self):
          super().__init__()
  
          folder_icon = QIcon.fromTheme("folder")
  
          self.setTitle("Basic Settings")
          self.setSubTitle("..........................."
                           "...........................")
  
          interpreterLabel = QLabel("&amp;Interpreter:")
          self.interprComboBox = QComboBox()
          interpreterLabel.setBuddy(self.interprComboBox)
  
          venvNameLabel = QLabel("Venv &amp;name:")
          self.venvNameLineEdit = QLineEdit()
          venvNameLabel.setBuddy(self.venvNameLineEdit)
  
          venvLocationLabel = QLabel("&amp;Location:")
          self.venvLocationLineEdit = QLineEdit()
          venvLocationLabel.setBuddy(self.venvLocationLineEdit)
  
          self.selectDirToolButton = QToolButton(icon=folder_icon)
          self.selectDirToolButton.setFixedSize(26, 27)
  
          placeHolder = QLabel()
  
          # options groupbox
          groupBox = QGroupBox("Options")
  
          self.withPipCBox = QCheckBox(
              "Install and update &amp;Pip"
          )
          self.sitePackagesCBox = QCheckBox(
              "&amp;Make system (global) site-packages dir available to venv"
          )
          self.symlinksCBox = QCheckBox(
              "Attempt to &amp;symlink rather than copy files into venv"
          )
          self.launchVenvCBox = QCheckBox(
              "Launch a &amp;terminal with activated venv after installation"
          )
          self.createButton = QPushButton(
              "&amp;Create", self,
              clicked=self.execute_venv_create,
          )
          self.createButton.setFixedWidth(90)
  
          # box layout containing the create button
          h_BoxLayout = QHBoxLayout()
          h_BoxLayout.setContentsMargins(495, 5, 0, 0)
          h_BoxLayout.addWidget(self.createButton)
  
          # grid layout
          gridLayout = QGridLayout()
          gridLayout.addWidget(interpreterLabel, 0, 0, 1, 1)
          gridLayout.addWidget(self.interprComboBox, 0, 1, 1, 2)
          gridLayout.addWidget(venvNameLabel, 1, 0, 1, 1)
          gridLayout.addWidget(self.venvNameLineEdit, 1, 1, 1, 2)
          gridLayout.addWidget(venvLocationLabel, 2, 0, 1, 1)
          gridLayout.addWidget(self.venvLocationLineEdit, 2, 1, 1, 1)
          gridLayout.addWidget(self.selectDirToolButton, 2, 2, 1, 1)
          gridLayout.addWidget(placeHolder, 3, 0, 1, 2)
          gridLayout.addWidget(groupBox, 4, 0, 1, 3)
          gridLayout.addLayout(h_BoxLayout, 5, 0, 1, 0)
          self.setLayout(gridLayout)
  
          # options groupbox
          groupBoxLayout = QVBoxLayout()
          groupBoxLayout.addWidget(self.withPipCBox)
          groupBoxLayout.addWidget(self.sitePackagesCBox)
          groupBoxLayout.addWidget(self.symlinksCBox)
          groupBoxLayout.addWidget(self.launchVenvCBox)
          groupBox.setLayout(groupBoxLayout)
  
      def execute_venv_create(self):
          """
          Execute the creation process.
          """
          # do something, then display info message
          QMessageBox.information(self, "Done", "message text")
          # when user clicks 'Ok', go to the next page defined in .nextId
  
  </code></pre>
  
  <hr>
  
  <pre class="lang-python prettyprint-override"><code>class InstallPackages(QWizardPage):
      """
      Install packages via `pip` into the created virtual environment.
      """
      def __init__(self):
          super().__init__()
  
          self.setTitle("Install Packages")
          self.setSubTitle("..........................."
                           "...........................")
  
          verticalLayout = QVBoxLayout()
          gridLayout = QGridLayout(self)
  
          pkgNameLabel = QLabel("Package name:")
          self.pkgNameLineEdit = QLineEdit()
          self.searchButton = QPushButton("Search")
          resultsTable = QTableView(self)
  
          gridLayout.addWidget(pkgNameLabel, 0, 0, 1, 1)
          gridLayout.addWidget(self.pkgNameLineEdit, 0, 1, 1, 1)
          gridLayout.addWidget(self.searchButton, 0, 2, 1, 1)
          gridLayout.addWidget(resultsTable, 1, 0, 1, 3)
  
          verticalLayout.addLayout(gridLayout)
  
          # ...
  </code></pre>
  
  <hr>
  
  <pre class="lang-python prettyprint-override"><code>class Summary(QWizardPage):
      def __init__(self):
          super().__init__()
  
          self.setTitle("Summary")
          self.setSubTitle("..........................."
                           "...........................")
  
          # ...
  
      def initializePage(self):
          pass
  
  
  if __name__ == "__main__":
      import sys
  
      app = QApplication(sys.argv)
      wiz = VenvWizard()
      wiz.exec_()
  
      sys.exit(app.exec_())
  </code></pre>