pythonwxpythonlistctrl

wxPython how to get row ID of list item that is double clicked


I am working on a wxPython app in which I have used a wx.ListCtrl with 12 columns. The control gets populated with some values upon clicking a button... let's say Name, Age, Class, House... etc.

Now I want to create a double click event which upon double cliking a list item should pop-up a msgbox with the Name value, however I am unable to get the row number or ID of the row item that is being double clicked...

here is my Code:-

self.subList.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.DblClickOptions)

def DblClickOptions(self, extra):
    itm = self.subList.GetItem(itemId='???', col=1)
    itm_text = itm.GetText()
    ctypes.windll.user32.MessageBoxA(0, itm_text, "title", 1)

in the code above I need to get the row number of the list item that is double clicked in place of '???'

Please someone help me with this.

Regards, Premanshu


Solution

  • http://xoomer.virgilio.it/infinity77/wxPython/Events/wx.ListEvent.html#methods-summary

    (typically the variable you named extra is named event or evt ...)

    extra.GetIndex() would be the row id

    extra.GetText() would be the row text

    etc