[wxPython-users] Re: EVT_PAINT handler raising excption, gets called repeatedly

Charl P. Botha cpbotha at cpbotha.net
Tue Jul 3 14:02:22 PDT 2007


On 7/3/07, Christian K. <ckkart at hoc.net> wrote:
> Charl P. Botha wrote:
> > Dear all,
> >
> > I'm running on Windows XP SP2 and wxPython 2.6.3.3.  If an EVT_PAINT
> > handler is raising an exception (and thus not returning normally), is
> > there any reason why it would then be repeatedly called?  If I catch
> > the exception inside the event handler, it behaves as expected.
>
> EVT_PAINT handlers are obviously called by the wxPython event system, so
> there is no way to put try: except around the call. Where in your code
> have you hoped that exception handling could catch exceptions occuring
> inside the handler?

I have a custom EVT_PAINT handler, let's call it OnPaint.  OnPaint
makes a call to another method, which could raise an exception.  I'm
curious as to what wxPython's event handling does with this handler,
as it does not exit normally, due to the exception raised by the
method it calls.  I've solved the problem by setting event.Skip()
_before_ calling the exception-raising method, but I'm still curious.




More information about the wxpython-users mailing list