ich wollte ein kleines zusätzliches Demo in wxPython schreiben.
Wenn es als standalone aufgerufen wird, passt das.
(Es wird eine Messagebox ausgegeben und das Programm dann beendet)
Wenn es jedoch innerhalb von Demo aufgerufen wird,
sollte sich das Programm verabschieden, ohne dass es zusätzliche
Fehlermeldungen ausgibt.
Es sollte auch nicht mit sys.exit beendet werden.
(Da ich sonst im Demo die Meldung sehe,
(wo ich vorher eh schon eine Messagebox ausgegeben habe und
deshalb unnötig ist, und wie ein Fehler aussieht))
also:
in der Zeile:
#here I want to stop reading the file at once, so no traceback and no error occurs.
sollte der Python Interpreter veranlasst werden, den Rest des Files
zu ignorieren.
Hat jemand eine Lösung dafür?
Danke im voraus!
Code: Alles auswählen
#!/usr/bin/env python
# Franz Steinhaeusler, 10.05.2006
# TestAutoFind.py Demo Application
import wx
try:
from wx.lib.mixins.autofind import *
except:
import sys
#needed for demo
appnotrunning = wx.GetApp() is None
if appnotrunning:
app = wx.App()
wx.MessageBox("No module autofind in wx/lib/mixins found.\nPlease copy it to this place!", "Fatal Error")
if appnotrunning:
app.MainLoop()
sys.exit(1)
else:
#here I want to stop reading the file at once, so no traceback and no error occurs.
class ChoiceAutoFind(wx.Choice, AutoFindMixin):
"""ChoiceAutoFind: Demo Class to present the AutoFindMixin class with a wx.Choice."""
def __init__(self, parent, id=-1, pos=wx.DefaultPosition,
size=wx.DefaultSize, choices=[], style=0, showbuffer=False):
"""Create the ChoiceAutoFind Control."""
wx.Choice.__init__(self, parent, id, pos, size, choices, style)
AutoFindMixin.__init__(self, parent, showbuffer)
#...
#...