wxpython: problem with events and checklistbox

Robert Amesz sheershion at mailexpire.com
Tue Apr 2 22:13:41 EST 2002


Marcus Stojek wrote:

> in my GUI I have a wxCheckListBox (named CheckList) and an fuction
> IfChecked(self,event) that process the checkevents (EVT_CHECLISTBOX).
> 
> Now, when unpickling all data at the start of my program,
> I want to check some items with CheckList.check(index,true)
> My problem is, that after each checking the function IfChecked is
> called. In the docs I found something about PopEventHandler, but this
> doesn't seem to solve my problem. Again, this should be an all day
> problem, but I have no idea where to look.

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.

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.

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.)


HTH, Robert Amesz



More information about the Python-list mailing list