title: PySide how to set focus to new window and open it if not exists
body: <p>I have started learning PySide from <a href="http://zetcode.com/gui/pysidetutorial/menusandtoolbars/" rel="nofollow">example of Zetcode</a> and try to code app which had two windows: "Schematic View" which is parent of "Layout View", each with menu bar. On start that should be only schematic window, and layout win should be started by switchtoLAYOUT in root of menubar. </p>
  
  <p>My questions are: </p>
  
  <ol>
  <li>How to make "switchtoLAYOUT" in root not to show the dropdown and still do action with only one instance of "Layout View" window ? </li>
  <li>How to switch the focus between two windows ("switchtoLAYOUT" and "switchtoSCHEMATIC")?</li>
  <li>Please inspect my code and suggest me something smart (that should not be hard). </li>
  </ol>
  
  <p>The Code:</p>
  
  <pre><code>import sys
  from PySide import QtCore, QtGui
  
  class schematicWindow(QtGui.QMainWindow):
  
      def __init__(self):
          super(schematicWindow, self).__init__()
          self.defineSchWin()
  
      def defineSchWin(self):               
          exitAction = QtGui.QAction('&amp;Exit', self)
          exitAction.setShortcut('Ctrl+Q')
          exitAction.setStatusTip('Exit application')
          exitAction.triggered.connect(self.close)
  
          self.statusBar()
  
          menubar = self.menuBar()
          fileMenu = menubar.addMenu('&amp;File')
          fileMenu.addAction(exitAction)
          menubar.addMenu('&amp;Edit')
          menubar.addMenu('&amp;Passives')
          menubar.addMenu('&amp;Descretes')
          menubar.addMenu('&amp;IC\'s')
          swToLayMenu = menubar.addMenu('switchtoLAYOUT')
          swToLayAction = QtGui.QAction(self)
          swToLayAction.triggered.connect(self.layoutWindow)
          swToLayMenu.addAction(swToLayAction)    # open layoutWindow (if not exists) 
                                                  # and set focus to layoutWindow 
  
          self.setGeometry(0, 300, 500, 300)
          self.setWindowTitle('Schematic View')    
          self.show()
  
      def layoutWindow(self):
          window = QtGui.QMainWindow(self)
          window.setAttribute(QtCore.Qt.WA_DeleteOnClose)
  
          window.statusBar()
          menubar = window.menuBar()
          switchtoSchMenu = menubar.addMenu('switchtoSCHEMATIC')
          window.setGeometry(100, 600, 500, 300)
          window.setWindowTitle('Layout View')
          window.show()
  
  def main():
  
      app = QtGui.QApplication(sys.argv)
      ex = schematicWindow()
      sys.exit(app.exec_())
  
  if __name__ == '__main__':
      main()
  </code></pre>