wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
5.75k stars 1.69k forks source link

Some wxPython apps kill the interpreter #20052

Closed wxtrac closed 2 years ago

wxtrac commented 21 years ago

Issue migrated from trac ticket # 687

component: wxPython | priority: normal

2002-12-19 17:21:58: anonymous created the issue


system: MS Windows 2000 Pro (wxPython 2.3.4.1 on Python 2.2.2)

code: from wxPython.wx import *

class BugApp(wxApp): def OnInit(self): print "running the app" return 0

print "about to run the app" app = BugApp(0) app.MainLoop() print "finished running the app"

output should be: about to run the app running the app finished running the app

actual output: about to run the app running the app

The wxApp object kills the whole interpreter when the app doesn't want to process its MainLoop. This behaviour may be intentional on the part of the designer, but it is not the behaviour I expect, and I think it should be changed.

This also causes inconsistent behaviour with wxApp.OnExit, although that may be intentional too.

traceback from PythonWin: Traceback (most recent call last): File "C:\PROGRA~1\PYTHON22\lib\site-packages\Pythonwin\pywin\scintilla\bindings.py", line 141, in fire rc = apply(binding.handler, args) File "C:\PROGRA~1\PYTHON22\lib\site-packages\Pythonwin\pywin\framework\interact.py", line 471, in ProcessEnterEvent if self.interp.runsource(source, "<interactive input>"): # Need more input! File "C:\PROGRA~1\PYTHON22\lib\code.py", line 87, in runsource self.runcode(code) File "C:\PROGRA~1\PYTHON22\lib\site-packages\Pythonwin\pywin\framework\interact.py", line 257, in runcode exec code in self.globals, self.locals File "", line 1, in ? File "C:\PROGRA~1\PYTHON22\lib\site-packages\wxPython\wx.py", line 1744, in init _wxStart(self.OnInit) SystemExit: OnInit returned FALSE, exiting...

wxtrac commented 21 years ago

2002-12-27 22:28:08: @RobinD42 commented


Not really intentional (well not for any reason that matters anymore anyway,) but it's the way it's always been and changing it would surly break some people's code.

You can always catch and ignore the SystemExit exception if you want to contue without exiting.