It seems to work only for the first column:
import wx
class MainWindow(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.panel = wx.Panel(self)
self.list = wx.ListCtrl(self.panel, style=wx.LC_REPORT)
self.list.InsertColumn(0, "No.")
self.list.InsertColumn(1, "Description")
self.list.Arrange()
for i in range(1, 6):
self.list.Append(["It's %d" % (i), "", ""])
# DOES NOT WORK! self.list.Append(["", "It's %d" % (i), ""])
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.list, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
self.panel.SetSizerAndFit(self.sizer)
self.Show()
print(self.list.FindItem(-1, "It's 4"))
app = wx.App(False)
win = MainWindow(None)
app.MainLoop()
There is more complex way how to add items to the list by creating wx.ListItem()
and SetItemData
can be used to add more data to the item. Then you can probably do FindItemData
. But I have never done that, so I cannot be of assistance.