4

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 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

2 Comments

Perfect. Thanks for the website =D I've had trouble finding good documentation.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.