4
votes

I'm using a ListCtrl and it is populated with items on the fly, when an item is "Activated"(Double Click/Enter) it calls a function.

    def onClick(self, event):

How do I find out which item was clicked in the List since they don't have pre-set IDs? Is the String passed to the function as part of self or event?

Thanks.

2

2 Answers

4
votes

Try event.GetText() or event.GetItem().<manipulate your item here>; here is wx.ListEvent documentation.

0
votes

Since you are probably binding the ListCtrl with the event, the ListCtrl item gets passed inside the event;

list = event.GetEventObject()
selected_string = list.GetStringSelection()

So now you have all ListCtrl methods available inside the event handler.

http://www.wxpython.org/docs/api/wx.Event-class.html

http://www.wxpython.org/docs/api/wx.TextCtrl-class.html