title: PyQT: How to call Dialog from within another Dialog (QMainWindow)
body: <p>Running a code posted below brings a <strong>Dialog_01</strong> QMainWindow with one button on it.
  Clicking the button should close this window (<strong>Dialog_01</strong>) and replace it with another: <strong>Dialog_02</strong> which is practically a copy of the first. Clicking <strong>Dialog_02</strong> button closes it and reopens <strong>Dialog_01</strong>. 
  There are no errors while the code runs. But it is definitely missing something since Dialog_02 is not showing up even while it is being declared. What am I missing? </p>
  
  <pre><code>from PyQt4 import QtCore, QtGui    
  
  
  class Dialog_02(QtGui.QMainWindow):
      def __init__(self):
          super(Dialog_02, self).__init__()
  
          myQWidget = QtGui.QWidget()
          myBoxLayout = QtGui.QVBoxLayout()       
  
          Button_02 = QtGui.QPushButton("Press to close this dialog 02 and re-open Dialog 01")
          Button_02.clicked.connect(self.callAnotherQMainWindow)
          myBoxLayout.addWidget(Button_02)
  
          myQWidget.setLayout(myBoxLayout)
          self.setCentralWidget(myQWidget)
  
      def callAnotherQMainWindow(self):
          print "This is supposed to call Dialog_01"
  
  
  
  class Dialog_01(QtGui.QMainWindow):
      def __init__(self):
          super(Dialog_01, self).__init__()
  
          myQWidget = QtGui.QWidget()
          myBoxLayout = QtGui.QVBoxLayout()       
  
          Button_01 = QtGui.QPushButton("Press to close this dialog and open Dialog 02")
          Button_01.clicked.connect(self.callAnotherQMainWindow)
          myBoxLayout.addWidget(Button_01)        
  
          myQWidget.setLayout(myBoxLayout)
          self.setCentralWidget(myQWidget)
  
      def callAnotherQMainWindow(self):
          dialog_1.hide()
  
          dialog_2 = Dialog_02()
          dialog_2.resize(480,320)
          dialog_2.show()
          dialog_2.raise_() 
  
  
  dialog_1 = Dialog_01()
  dialog_1.show()
  dialog_1.resize(480,320)
  sys.exit(app.exec_())
  </code></pre>
  
  <h1>EDITED LATER: WORKING FIXED VERSION</h1>
  
  <p>The mistake was in using dialog.hide() instead of dialog.close(). A calling dialog needs to be closed (instead of hidden) before a second dialog can be displayed.</p>
  
  <pre><code>from PyQt4 import QtCore, QtGui    
  app = QtGui.QApplication(sys.argv)
  
  class Dialog_02(QtGui.QMainWindow):
      def __init__(self):
          super(Dialog_02, self).__init__()
  
          myQWidget = QtGui.QWidget()
          myBoxLayout = QtGui.QVBoxLayout()       
  
          Button_02 = QtGui.QPushButton("Press to close this dialog 02 and re-open Dialog 01")
          Button_02.clicked.connect(self.callAnotherQMainWindow)
          myBoxLayout.addWidget(Button_02)
  
          myQWidget.setLayout(myBoxLayout)
          self.setCentralWidget(myQWidget)
          self.setWindowTitle('Dialog 02')
  
      def callAnotherQMainWindow(self):
          self.close()
          self.dialog_01 = Dialog_01()
          self.dialog_01.show()
          self.dialog_01.raise_()
  
  
  
  class Dialog_01(QtGui.QMainWindow):
      def __init__(self):
          super(Dialog_01, self).__init__()
  
          myQWidget = QtGui.QWidget()
          myBoxLayout = QtGui.QVBoxLayout()       
  
          Button_01 = QtGui.QPushButton("Press to close this dialog and open Dialog 02")
          Button_01.clicked.connect(self.callAnotherQMainWindow)
          myBoxLayout.addWidget(Button_01)        
  
          myQWidget.setLayout(myBoxLayout)
          self.setCentralWidget(myQWidget)
          self.setWindowTitle('Dialog 01')
  
      def callAnotherQMainWindow(self):
          self.close()
          self.dialog_02 = Dialog_02()
          self.dialog_02.show()
          self.dialog_02.raise_()
  
  dialog_1 = Dialog_01()
  dialog_1.show()
  dialog_1.resize(480,320)
  sys.exit(app.exec_())
  </code></pre>