[wxPython] Odd Error on Closing WxPython App

I have a fairly small wxPython app which I’m just getting back to after not touching it for a year or so. It’s been running fine (apparently) under Win98 and WinNT, and appears to run fine under Win2K.

But, I just started playing with Boa Constructor; not using any of the widgets, just using it as a debugging editor. When I exit the application from any of the “preliminary” screens, I get no error. However the “normal” finish for the application presents a simple dialog with an “OK” button. Code is as follows:

    MsgText = "Goodbye!"
    dlg = wxMessageDialog(self, MsgText, 'Logout Successful', wxOK | wxICON_INFORMATION)
    dlg.ShowModal()
    dlg.Destroy()
    sys.exit()

Clicking the button appears to close the app but generates the error text in Boa, which I’m afraid I don’t begin to understand, and leaves some remnant running which I have to kill to shut down Win2K. Any help greatly appreciated.

John Hopkins

06:07:33 PM: Debug: c:\Projects\wx\src\msw\app.cpp(535): ‘UnregisterClass(canvas)’ failed with error 0x00000584 (class still has open windows.).
06:07:33 PM: There were memory leaks.
06:07:33 PM: ----- Memory dump -----
06:07:33 PM: wxFrame at $8E7108, size 332
06:07:33 PM: wxPanel at $B64C18, size 264
06:07:33 PM: wxStaticText at $B648E8, size 264
06:07:33 PM: wxButton at $B74EB8, size 264
06:07:33 PM: wxPyCallback at $B64EF8, size 12
06:07:33 PM: wxObject at $B74880, size 28
06:07:33 PM:
06:07:33 PM:
06:07:33 PM: ----- Memory statistics -----
06:07:33 PM: 1 objects of class wxObject, total size 28
06:07:33 PM: 1 objects of class wxPyCallback, total size 12
06:07:33 PM: 1 objects of class wxButton, total size 264
06:07:33 PM: 1 objects of class wxStaticText, total size 264
06:07:33 PM: 1 objects of class wxPanel, total size 264
06:07:33 PM: 1 objects of class wxFrame, total size 332
06:07:33 PM:
06:07:33 PM: Number of object items: 6
06:07:33 PM: Number of non-object items: 0
06:07:33 PM: Total allocated size: 1164
06:07:33 PM:
06:07:33 PM:

···

        MsgText = "Goodbye!"
        dlg = wxMessageDialog(self, MsgText, 'Logout Successful',
                              wxOK | wxICON_INFORMATION)
        dlg.ShowModal()
        dlg.Destroy()
        sys.exit()

Clicking the button appears to close the app but generates the
error text in Boa, which I'm afraid I don't begin to understand,
and leaves some remnant running which I have to kill to shut down
Win2K. Any help greatly appreciated.

Don't do the sys.exit(). You need to let wxWindows shut itself down
normally in order for it to clean up all the windows and resources it is
using. The best way to "exit normally" is simply to Close or Destroy all
top level windows. The next iteration of the MainLoop will notice that
there are no more windows left and will cleanup everything else and then
MainLoop will return.

···

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