[wxpython-users] Fwd: Trouble with CheckListCtrl
Raffaello Barella
barbarossa.platz at gmail.com
Sat Apr 5 22:13:39 PDT 2008
If you want to call a function when an item is checked, you have to
intercept an event (usually, I think, wx.EVT_LIST_ITEM_SELECTED or
wx.EVT_LIST_ITEM_DESELECTED). So put in the __init__ of your frame the
following:
self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelectedItem,
self.chkList)
and then build your function:
def OnSelectedItem(self, event):
event.Skip() # look the documentation for this command
do stuff...
Bye
2008/4/6, Marc Tompkins <marc.tompkins at gmail.com>:
>
> On Sat, Apr 5, 2008 at 2:50 PM, Patrick Guido Arminio <
> patrick.arminio at gmail.com> wrote:
>
> > I've create a simple gui that uses the widget CheckListCtrl (I found the
> > base code here: http://zetcode.com/wxpython/advanced/), but I've a
> > problem: I don't know how to call a function when an item is checked, c=
an
> > you help me?
> >
>
> I use the CheckListCtrl myself, and I don't use events with it at all.
> Are you sure you want to/need to?
> My app presents a list of insurance companies; the user can select some or
> all of them (I also have buttons for Select All/Clear All), and then hit =
the
> Print Labels button. When she does :
> num =3D self.chkList.GetItemCount()
> for i in range(num):
> if self.chkList.IsChecked(i):
> doStuff()....
>
> You _might_ really need to do something each time an item is selected or
> deselected - I wouldn't want to dictate to you - but if, like me, all you
> need is to keep track of which items are checked and which aren't... relax
> and let the widget take care of it!
>
> --
> www.fsrtechnologies.com
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200804=
06/8bee2a3a/attachment.htm
More information about the wxpython-users
mailing list