Error message when exiting wxpython application

Hi,

I have bind the following function to my wxpython application’s close button:

def OnClose(self, event):
    self.Destroy()
    print "destroyed xxx"
    sys.exit(1)    

When I close the application, I get the following error:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File “C:\Python27\lib\atexit.py”, line 24, in _run_exitfuncs
func(*targs, **kargs)
PyAssertionError: C++ assertion “m_count > 0” failed at …\src\common\object.cpp(353) in wxRefCounter::DecRef(): invalid ref data count
Error in sys.exitfunc:
Traceback (most recent call last):
File “C:\Python27\lib\atexit.py”, line 24, in _run_exitfuncs
func(*targs, **kargs)
wx._core.PyAssertionError: C++ assertion “m_count > 0” failed at …\src\common\object.cpp(353) in wxRefCounter::DecRef(): invalid ref data count

Could you please help, what does that error message mean and how can I fix it?

Best regards

This is not the right way to do this. OnClose is called in response
to a window message, but it is far from the last window message your
app will receive. Call self.Destroy, but then just return. When
the last window in your app closes, the framework will post a “quit”
message, which causes the message loop to exit, which means your
call to PyApp.MainLoop will return, and your script will terminate
normally.

···

steve wrote:

Hi,

    I have bind the following function to my wxpython application's

close button:

                  def

OnClose(self, event):

              self.Destroy()

              print "destroyed xxx"

              sys.exit(1)    
-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.com