wxpython: problem with events and checklistbox

Marcus Stojek stojek at part-gmbh.de
Wed Apr 3 03:48:35 EST 2002


>Well the first hint would be to ask yourself if you really need that 
>event handler in the first place. If it can't cope with the program 
>setting or removing the checkmarks in the control, chances are it won't 
>handle user input any better or more gracefully. You might want to 
>reconsider your design.

Believe it of not, i changed the design ;-)
Anyway I think there should be a way to distiguish between events
triggered by the user (check with mouseclick) and triggered by a
function (List.Check(i,true)). At least there should be a way to kill
an event right after it had been raised by a function.

>
>But apart from that, there are two very simple solutions:
>
>1. Don't set the event handler in the __init__ of your class, but do it 
>after you've set all the checks you want.
Doesn't work for this problem, but is a very good hint for another
one.
>
>2. Use a flag somewhere in your class, and check (in another sense of 
>the word, no pun intended) that flag at the start of your event 
>handler. Simply do a return if the flag indicates the event handler 
>should be temporarily disabled. (You could even do event.Skip() prior 
>to that return if you want that event to propagate to the parent 
>window, but somehow I don't think that's needed here.)
That's what I did prior to my posting. But as I don't know very much
about eventhandling I thought there should be a better way.

Thanks to all of you.
Marcus




More information about the Python-list mailing list