title: How can I switch to another screen (without opening a new window) in Pyqt5
body: <p>I know this question has been asked multiple times but I am having a hard time to understand examples, so all I have this first screen and I want, when I click on this <code>Go to page 2 button</code>, It should switch to the <code>second screen</code> without opening a different window.</p>
  <p>step -1 Click on <code>Go to page 2 button</code></p>
  <p><a href="https://i.stack.imgur.com/tpp0e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tpp0e.png" alt="Click on &quot;Go to page 2 &quot; button" /></a></p>
  <p>step -2 Switch to <code>2nd screen</code></p>
  <p><a href="https://i.stack.imgur.com/aGck7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aGck7.png" alt="Switch to 2nd screen" /></a></p>
  <p>step -3 Switch Back to <code>1st screen</code></p>
  <p>This is the code I have for both screens, I don't want to <em>loadUI</em> file</p>
  <p>################ <strong><code>File1.py</code></strong> ##############</p>
  <pre><code>class Ui_PageFirst(object):
      def setupUi(self, PageFirst):
          PageFirst.setObjectName(&quot;PageFirst&quot;)
          PageFirst.resize(123, 132)
          self.centralwidget = QtWidgets.QWidget(PageFirst)
          self.centralwidget.setObjectName(&quot;centralwidget&quot;)
          self.FirstPageLable = QtWidgets.QLabel(self.centralwidget)
          self.FirstPageLable.setGeometry(QtCore.QRect(0, 0, 121, 71))
          self.FirstPageLable.setAlignment(QtCore.Qt.AlignCenter)
          self.FirstPageLable.setObjectName(&quot;FirstPageLable&quot;)
          self.btn1 = QtWidgets.QPushButton(self.centralwidget)
          self.btn1.setGeometry(QtCore.QRect(20, 80, 75, 23))
          self.btn1.setObjectName(&quot;btn1&quot;)
          PageFirst.setCentralWidget(self.centralwidget)
  
          self.retranslateUi(PageFirst)
          QtCore.QMetaObject.connectSlotsByName(PageFirst)
  
      def retranslateUi(self, PageFirst):
          _translate = QtCore.QCoreApplication.translate
          PageFirst.setWindowTitle(_translate(&quot;PageFirst&quot;, &quot;MainWindow&quot;))
          self.FirstPageLable.setText(_translate(&quot;PageFirst&quot;, &quot;This is page First.&quot;))
          self.btn1.setText(_translate(&quot;PageFirst&quot;, &quot;Go to page 2&quot;))
  
  
  if __name__ == &quot;__main__&quot;:
      import sys
      app = QtWidgets.QApplication(sys.argv)
      PageFirst = QtWidgets.QMainWindow()
      ui = Ui_PageFirst()
      ui.setupUi(PageFirst)
      PageFirst.show()
      sys.exit(app.exec_())
  </code></pre>
  <p>################ <strong><code>File2.py</code></strong> ##############</p>
  <pre><code>class Ui_PageSecond(object):
      def setupUi(self, PageSecond):
          PageSecond.setObjectName(&quot;PageSecond&quot;)
          PageSecond.resize(123, 132)
          self.centralwidget = QtWidgets.QWidget(PageSecond)
          self.centralwidget.setObjectName(&quot;centralwidget&quot;)
          self.secondPageLable = QtWidgets.QLabel(self.centralwidget)
          self.secondPageLable.setGeometry(QtCore.QRect(0, 0, 121, 71))
          self.secondPageLable.setAlignment(QtCore.Qt.AlignCenter)
          self.secondPageLable.setObjectName(&quot;secondPageLable&quot;)
          self.btn2 = QtWidgets.QPushButton(self.centralwidget)
          self.btn2.setGeometry(QtCore.QRect(20, 80, 75, 23))
          self.btn2.setObjectName(&quot;btn2&quot;)
          PageSecond.setCentralWidget(self.centralwidget)
  
          self.retranslateUi(PageSecond)
          QtCore.QMetaObject.connectSlotsByName(PageSecond)
  
      def retranslateUi(self, PageSecond):
          _translate = QtCore.QCoreApplication.translate
          PageSecond.setWindowTitle(_translate(&quot;PageSecond&quot;, &quot;MainWindow&quot;))
          self.secondPageLable.setText(_translate(&quot;PageSecond&quot;, &quot;This is page Second.&quot;))
          self.btn2.setText(_translate(&quot;PageSecond&quot;, &quot;Go to page 1&quot;))
  
  
  if __name__ == &quot;__main__&quot;:
      import sys
      app = QtWidgets.QApplication(sys.argv)
      PageSecond = QtWidgets.QMainWindow()
      ui = Ui_PageSecond()
      ui.setupUi(PageSecond)
      PageSecond.show()
      sys.exit(app.exec_())
  </code></pre>