title: PyQt5 Switch between window after time in a loop
body: <p>i use the code below, found on stackoverflow. i want to build a loop which getting started with a button on the main window. After clicked window2 should open for 30 seconds. then window3 should open for 30 seconds. then window2 should open and so on.</p>
  <p>i make a slide methode but it wont work.</p>
  <p>i try it with the window2() and window3() and slide() methode</p>
  <p>what is my target?</p>
  <p>i want a slideshow with the two window(window2 &amp; window3) that alternate.
  not more but it is an endless loop</p>
  <pre><code>import sys
  from PyQt5 import QtGui
  from PyQt5.QtWidgets import (QApplication, QMainWindow, QPushButton, 
                               QToolTip, QMessageBox, QLabel)
  
  class Window2(QMainWindow):                           # &lt;===
      def __init__(self):
          super().__init__()
          self.setWindowTitle(&quot;Window22222&quot;)
  
  class Window3(QMainWindow):                           # &lt;===
      def __init__(self):
          super().__init__()
          self.setWindowTitle(&quot;Window333333&quot;)
  
  class Window(QMainWindow):
      def __init__(self):
          super().__init__()
  
          self.title = &quot;First Window&quot;
          self.top = 100
          self.left = 100
          self.width = 680
          self.height = 500
  
          self.pushButton = QPushButton(&quot;Start&quot;, self)
          self.pushButton.move(275, 200)
          self.pushButton.setToolTip(&quot;&lt;h3&gt;Start the Session&lt;/h3&gt;&quot;)
  
          self.pushButton.clicked.connect(self.window2)      
          
          
          self.pushButton1 = QPushButton(&quot;Start&quot;, self)
          self.pushButton1.move(20, 20)
          self.pushButton1.setToolTip(&quot;&lt;h3&gt;Start the Session&lt;/h3&gt;&quot;)
  
          self.pushButton1.clicked.connect(self.slide)           
  
          self.main_window()
          
  
      def main_window(self):
          self.label = QLabel(&quot;Manager&quot;, self)
          self.label.move(285, 175)
          self.setWindowTitle(self.title)
          self.setGeometry(self.top, self.left, self.width, self.height)
          self.show()
  
      
      
        def window2(self):                                             # &lt;===
          self.w2 = Window2()
          self.w2.show()
          time.sleep(5)
          self.w3 = Window3()
          self.w3.show()
          self.w2.hide()
          self.window3()
          
          #self.hide()
      def window3(self):                                             # &lt;===
          self.w3 = Window3()
          self.w3.show()
          time.sleep(5)
          self.w2 = Window2()
          self.w2.show()
          self.w3.hide()
          self.window2()
          
          #self.hide()
  
      def slide(self):
          print (&quot;slide&quot;)
          self.window2()
  
  
  if __name__ == &quot;__main__&quot;:
      app = QApplication(sys.argv)
      window = Window()
      sys.exit(app.exec())
  </code></pre>