[Tutor] Re: GUI die when execute sys.exit() (D-Man)
Peter He
qhe@ydyn.com
Wed, 27 Jun 2001 16:14:40 -0500
>Message: 8
>Date: Wed, 27 Jun 2001 15:40:27 -0400
>From: D-Man <dsh8290@rit.edu>
>To: "tutor-request-python.org" <tutor@python.org>
>Subject: Re: [Tutor] GUI die when execute sys.exit()
>
>On Wed, Jun 27, 2001 at 09:07:02AM -0500, Peter He wrote:
>| When I run it and click the button, the gui die and I got the following
>| message:
>|
>| >>> Unhandled exception while debugging...
>| Traceback (most recent call last):
>| File "C:\PP2ndEd\Examples\PP2E\Gui\Intro\gui3c.py", line 9, in quit
>| import sys; sys.exit() # retains the self+quit pair
>| SystemExit
>
>This is supposed to happen.
>
>| I am using Pythonwin IDE from ActiveStates and windows 2000. I got
>| the same problems when I run other similar examples from other books
>| too.
>
>Well, the debugger doesn't know it, but it is supposed to be that way ;-).
>
>
>sys.exit() works by raising the exception 'SystemExit'. This allows
>try-finally clauses to work to perform any cleanup necessary before
>the program terminates. You expected the program to quit (gui to
>die), didn't you <wink>? If you run the program outside of the
>debugger it will look fine (you won't see the stacktrace). Oh, yeah,
>I should mention that the current python IDEs (PythonWin and IDLE come
>to mind) run your code in the same interpreter the IDE runs in. If
>you call sys.exit(), well, it will exit <wink>. (I guess that's what
>you meant, PythonWin died, not "the gui")
>
>-D
I used 'GUI die' in my last question. What I actually meant is that the GUI
freezes. GUI is still there but you can't close it and no response when you
click the buttons on it. So I have to restart Python to get rid of it.
Peter