The main window does not close after calling the new script


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.

      #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 . 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.

subprocess.Popen('python', shell=True)