2.7 Problems: Strange Solution

Hello friends,

First of all, I am sorry about the double posting, but I didn’t any receive messages (but I can send to) from this list since October 21. So, it was just when I checked the wxpython site list archive that I saw your answers.

Well, It’s a strange world we live on. As I’ve told you, after upgrade to wxPython 2.7 every time I closed my app I got errors like “invalid instruction”, “bus error”, etc.

Below is the code I used to make the GUI run on my app:

projetotela = TelaApp(0)
GUI = projetotela.frame_principal
projetotela.MainLoop()

Following a python debugger tutorial to check my problem, I have changed this code to the following, so I could run it from a python console on a debugging session:

def app_start():
projetotela = TelaApp(0)
GUI = projetotela.frame_principal
projetotela.MainLoop()

app_start()

And it just worked! No debugging
needed. Just put this GUI starting code on a function, called the function, and I had no more error messages when closing my app.

Any hint why this happened? I am very curious about it…

By the way, one friend suggested replacing:

self.Destroy()

by

self.Hide()
wxCallAfter(self.Destroy)

It didn’t helped. But now that I discovered the strange workaround of putting GUI starting code on a function, both ending solutions works (destroy and callafter). Anyway, thank you very much.

I am very happy for my choice of Python and wxPython. It’s a very strong community we have here.

Best Regards,
Márcio Moreira

···

O Yahoo! está de cara nova. Venha conferir!

Marcio Moreira wrote:

Hello friends,

First of all, I am sorry about the double posting, but I didn't any receive messages (but I can send to) from this list since October 21. So, it was just when I checked the wxpython site list archive that I saw your answers.

Well, It's a strange world we live on. As I've told you, after upgrade to wxPython 2.7 every time I closed my app I got errors like "invalid instruction", "bus error", etc.

Below is the code I used to make the GUI run on my app:

projetotela = TelaApp(0)
GUI = projetotela.frame_principal
projetotela.MainLoop()

Following a python debugger tutorial to check my problem, I have changed this code to the following, so I could run it from a python console on a debugging session:

def app_start():
    projetotela = TelaApp(0)
    GUI = projetotela.frame_principal
    projetotela.MainLoop()

app_start()

And it just worked! No debugging needed. Just put this GUI starting code on a function, called the function, and I had no more error messages when closing my app.

Any hint why this happened? I am very curious about it...

It's the same problem I mentioned in my other email. There was a bug that could happen if some wx objects were being destroyed while the Python interpreter was in shutdown mode. By moving your code into a function then they are destroyed when the function exits, but Python hasn't yet started shutting down at that point. I've got a fix for this in place for the next release.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!