473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

wxPython MainLoop exception handling problem

Hi,

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\logger.py", line 711, in onTimer
a.index('notinlist')
ValueError
:
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
2 2239
ncf
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

((untested))

Sep 12 '05 #2
Well, it worked :)

Thanks a lot!

- Kreedz

Sep 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Anand | last post by:
I am calling a python script from LabVIEW. This is achieved by making a dll call to python22.dll. It works perfectly well for most of my code. I now want to throwup dialog boxes from python. It...
1
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
9
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
5
by: dynamo | last post by:
Hi everyone.I'm new to wxpython.And i have a little problem.I tried to run the following wxpython app code in IDLE for python25: import wx import os import re def z(a): for i in...
9
by: Tyler | last post by:
Hello All: I am currently working on a project to create an FEM model for school. I was thinking about using wxPython to gather the 12 input variables from the user, then, after pressing the...
19
by: [david] | last post by:
I'd like to refresh the display before I start the main loop. I have code like this: app = App() app.Show() app.long_slow_init() app.MainLoop()
1
by: [david] | last post by:
What am I doing wrong? I'm trying to capture stdErr in a multi-threaded program. This code crashes wxPython with /Py Assertion Error: C++ assertion "m_count=-1 || m_count=-2" failed/ What I'm...
3
by: Shafik | last post by:
Hello folks, I'm having an issue with mixing wxPython and threading ... I realize multi-threading always introduces subtle bugs, but the following scenario is just odd: I start a dummy...
4
by: Jimmy | last post by:
hi, all I'm having a problem with creating custom events in wxpython. I have a class A handling some data processing work and another class B of GUI matter. I need GUI to display information...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.