Dear all,
I would like to build a control list having 2 columns: the first one not editable, the second one editable.
In addition, each row would have a check box.
I tried to do something like that:
class EditableListCtrl(wx.ListCtrl, listmix.CheckListCtrlMixin, listmix.TextEditMixin):
def init(self, parent, ID=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
wx.ListCtrl.init(self, parent, ID, pos, size, style)
listmix.CheckListCtrlMixin.init(self)
listmix.TextEditMixin.init(self)
def OnCheckItem(self, index, flag):
print(index, flag)
THEN IN MY FRAME:
self.list_ctrl = EditableListCtrl(self, size=(1000,1000), style=wx.LC_REPORT|wx.BORDER_SUNKEN)
self.list_ctrl.InsertColumn(0, ‘First column’)
self.list_ctrl.InsertColumn(1, ‘Second column’)
self.list_ctrl.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnStartEditing)
for i in range(3):
self.list_ctrl.InsertStringItem(i, “TEST %d” % (i))
self.list_ctrl.SetStringItem(i, 1, “WRITE HERE SOMETHING”)
def OnStartEditing(self, evt):
if evt.m_col == 0:
evt.Veto()
else:
evt.Skip()
``
In this way it works, but if the row is selected (highlighted), I cannot check the box (because I’m applying a veto on the event).
I can check the box only for unselected rows.
Any idea for fixing it?
Thank you.
Robert