sys.exit causing error

I added a Close() as follows:

            self.Close()

            sys.exit()

When it terminates I get a "python.exe Application Error":

The instruction at "0x1e0155fd" referenced memory at "0x00000000". The
memory could not be "read". Click on OK to terminate the program.

Heimburger, Ralph P wrote:

In my wxPython app I have the following code (within a class):

        if maintmodes <> 'ADMINISTRATOR':

            msg='User ['+self.currentuser+'] is Not Authorized to use

this function!'

            result=self.showAlert(msg,'ATTENTION')

            sys.exit()

I run the app and the dialog displays. When I click OK I see the

following error in the console:

Debug: e:\Projects\wx2.4\src\msw\app.cpp(446): 'UnregisterClass(no

redraw canvas)' failed with error 0x00000584 (class still has open

windows.).

Because you still have windows that exist and you forced the exit of the

app without giving wx a chance to cleanup after itself. Try using

wx.GetApp().ExitMainLoop() instead, although the safest is to just call

Close(True) on all your top-level windows.

···

--

Robin Dunn

Software Craftsman

http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------

To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org

For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Heimburger, Ralph P wrote:

I added a Close() as follows:

            self.Close()

            sys.exit()

Don't call sys.exit(). The app's MainLoop will automatically return when all top-level windows have been destroyed, allowing your app to exit normally.

···

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