Maybe this will work for you.
I use this code to capture the errors to a file. This code is from the
demo code.
Put this in your main:
if __name__ == '__main__':
···
#
# Redirect python exceptions to a file
#
sys.stderr = ExceptionHandler()
and you'll be all set.
================================================================
#
# Dutifully re-used from demo code
#
class ExceptionHandler:
""" A simple error-handling class to write exceptions to a text file.
Under MS Windows, the standard DOS console window doesn't scroll and
closes as soon as the application exits, making it hard to find and
view Python exceptions. This utility class allows you to handle Python
exceptions in a more friendly manner.
"""
def __init__(self):
""" Standard constructor.
"""
self._buff = ""
if os.path.exists("errors.txt"):
os.remove("errors.txt") # Delete previous error log, if any.
def write(self, s):
""" Write the given error message to a text file.
Note that if the error message doesn't end in a carriage return, we
have to buffer up the inputs until a carriage return is received.
"""
if (s[-1] != "\n") and (s[-1] != "\r"):
self._buff = self._buff + s
return
try:
s = self._buff + s
self._buff = ""
if s[:9] == "Traceback":
# Tell the user than an exception occurred.
wxMessageBox("An internal error has occurred.\nPlease " + \
"refer to the 'errors.txt' file for details.",
"Error", wxOK | wxCENTRE | wxICON_EXCLAMATION)
f = open("errors.txt", "a")
f.write(s)
f.close()
except:
pass # Don't recursively crash on errors.
On Fri, 2004-01-09 at 21:39, Jeff Grimmett wrote:
> Thx, I just did that and I have the pop-up. However, it disappears
> immediatly if the exception occurs during MyApp.OnInit. It there's a
> way to keep it even in that case?
Ooo, black magic voodoo kinda stuff. MAYBE you could use wx.lib.ErrorDialogs
to get around this, but I'm dubious about it.
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org
--
Jim West
CheckLogix -a Concord company
102 S. Tejon Ste 920, Colorado Springs, CO 80903
719.633.7005 x223 Fax: 719.633.7006 Cell: 719.660.5676