title: Limit number of class instances with python
body: <p>Μy Mainclass creates a simple <code>QmainWindows</code> like this:</p>
  
  <pre><code>class mcManageUiC(QtGui.QMainWindow):
      def __init__(self):
          super(mcManageUiC, self).__init__()
  
          self.initUI()
  
      def initUI(self):
          self.show()
  </code></pre>
  
  <p>And at the end of my file I launch it like this:</p>
  
  <pre><code>def main():
      app = QtGui.QApplication(sys.argv)
      renderManagerVar = mcManageUiC()
      sys.exit(app.exec_())
  
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>My problem is that each time i source it, it launches a new window. 
  I would like to know if there is a way to detect existence of previous class instance in my script (so that I close the old one or avoid launching a new one), or any other solutions?</p>
  
  <p>Also, when compiling my code with py2exe, same problem with my .exe file on Windows; it launchs a new window every time. Could i add something in the setup.py for Windows to not act like this?</p>
  
  <p>Is it possible, if yes then how?</p>
  
  <p>Note: I'm using Windows 7 64bit compiling with eclipse.</p>