The main window does not close after calling the new script

advertisements

I am learning python and for GUI model using wxpython, as I am new to programing get stuck every time. My issue is I have a GUI (main window)with two buttons,when user clicks button1 it opens sub window (seperate python script), I want to close or destroy main window before opening sub window.

      self.Destroy()
      subprocess.call("python newframe.py",shell=True)
      #It will not close main window

What will be the wrong i am trying to do , and please explain what is proper method.

Looking for suggestions thanks . Sorry for my english .


subprocess.call() wait subprocess to exit. -> button callback will never return until subprogram exit. This keep main window to close. Use subprocess.Popen() which does not wait subprocess.

self.Destroy()
subprocess.Popen('python newframe.py', shell=True)