Restart wxPython Application - python crash

I am trying to restart my app using the code below:

MyApp(0).MainLoop()

if restart:
   MyApp(0).MainLoop()

when running my app , it is restarted and shown, but after about a sek
python crashes
and a windows appears "python.exe has stopped working ... Windows can
check online for s solution to the problem , etc..."

What can be the reason for this?

MyAPP:

class MyApp(wx.App):
     def OnInit(self):
        global restart restart = False
        win = MainFrame(None)
        win.Show(True)
        self.SetTopWindow(win)
        return True

···

On Jan 7, 10:25 am, Michael Gorelik <smgore...@gmail.com> wrote:

I am trying to restart my app using the code below:

MyApp(0).MainLoop()

if restart:
MyApp(0).MainLoop()

when running my app , it is restarted and shown, but after about a sek
python crashes
and a windows appears "python.exe has stopped working ... Windows can
check online for s solution to the problem , etc..."

What can be the reason for this?

i forgot to mention that i am using windows 7 , python 27

···

On Jan 7, 10:27 am, Michael Gorelik <smgore...@gmail.com> wrote:

MyAPP:

class MyApp(wx.App):
def OnInit(self):
global restart
        restart = False
win = MainFrame(None)
win.Show(True)
self.SetTopWindow(win)
return True
On Jan 7, 10:25 am, Michael Gorelik <smgore...@gmail.com> wrote:

> I am trying to restart my app using the code below:

> MyApp(0).MainLoop()

> if restart:
> MyApp(0).MainLoop()

> when running my app , it is restarted and shown, but after about a sek
> python crashes
> and a windows appears "python.exe has stopped working ... Windows can
> check online for s solution to the problem , etc..."

> What can be the reason for this?

It is best to not create more than one instance of the App object in a single process. You'll be better off to have the process relaunch itself (using sys.executable + script name for example) or to simply create and show a new instance of the main frame when it is closed rather than waiting for MainLoop to exit.

···

On 1/7/12 12:25 AM, Michael Gorelik wrote:

I am trying to restart my app using the code below:

MyApp(0).MainLoop()

if restart:
    MyApp(0).MainLoop()

when running my app , it is restarted and shown, but after about a sek
python crashes
and a windows appears "python.exe has stopped working ... Windows can
check online for s solution to the problem , etc..."

What can be the reason for this?

--
Robin Dunn
Software Craftsman

Thanks, creating a new instance of the inner panel has solved the
issue for me.

···

On Jan 9, 8:14 am, Robin Dunn <ro...@alldunn.com> wrote:

On 1/7/12 12:25 AM, Michael Gorelik wrote:

> I am trying to restart my app using the code below:

> MyApp(0).MainLoop()

> if restart:
> MyApp(0).MainLoop()

> when running my app , it is restarted and shown, but after about a sek
> python crashes
> and a windows appears "python.exe has stopped working ... Windows can
> check online for s solution to the problem , etc..."

> What can be the reason for this?

It is best to not create more than one instance of the App object in a
single process. You'll be better off to have the process relaunch
itself (using sys.executable + script name for example) or to simply
create and show a new instance of the main frame when it is closed
rather than waiting for MainLoop to exit.

--
Robin Dunn
Software Craftsmanhttp://wxPython.org