By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,907 Members | 1,932 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,907 IT Pros & Developers. It's quick & easy.

wxPython MainLoop exception handling problem

P: n/a

I'm making some intelligent logging module that redirects stdout and
stderr of a wxPython GUI. I am logging the exceptions in a wx TreeCtrl.
My problem is that when an exception is thrown, there are many calls to
stderr that are made which gives this kind of result:

Traceback (most recent call last):
File "C:\somefolder\", line 711, in onTimer
list.index(x): x not in list

(That is a test exception I made...)

Obviously I would not want it to use so many lines in the TreeCtrl, and
the lonely ":" on its line looks weird.

I looked through the wx App and saw the "OnExceptionInMainLoop"
function but could not override it successfully. Anybody have an idea
on how I could handle the exception myself so that I dont get lots of
calls to stderr ?

Thanks a lot!

- Kreedz

Sep 12 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Errm, maybe you could use the sys.excepthook function to catch the
error and then print the details yourself from the traceback object.

import sys
def _exceptionhook(type, value, traceback):
''' your code here '''
sys.excepthook = _exceptionhook


Sep 12 '05 #2

P: n/a
Well, it worked :)

Thanks a lot!

- Kreedz

Sep 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.