self.testParameters = self.testParameterListCtrl(self, -1, style=wx.LC_REPORT |wx.LC_HRULES | wx.LC_VRULES | wx.LC_SINGLE_SEL)
self.testParameters.InsertColumn(0, "Parameter", wx.LIST_FORMAT_CENTER, -1)
self.testParameters.InsertColumn(1, "Value", wx.LIST_FORMAT_CENTER, -1)
self.testParameters.Bind(wx.EVT_LIST_END_LABEL_EDIT, self.onModifyTestParameter )
for parameter, value in self.keywordArgs.iteritems():
self.testParameters.InsertStringItem(index, parameter, 0)
self.testParameters.SetStringItem(index, 1, str(value))
if parameter in self.workloadTests.values():
self.testParameters.SetStringItem(index, 1, self.testWorkload.GetValue())
# Cell Colors
if (index % 2):
self.testParameters.SetItemBackgroundColour(index, self.listBGColor_1)
else:
self.testParameters.SetItemBackgroundColour(index, self.listBGColor_2)
index += 1
In this code, I want disable '0' index "parameter" as non editable listCtrl and '1' index 'value" as editable listCtrl.
You can do this using an EditableListCtrl from
import wx.lib.mixins.listctrl as listmix
Create a class for the mix in
class EditableListCtrl(wx.ListCtrl, listmix.TextEditMixin):
# TextEditMixin allows any column to be edited other than those specifically vetoed
def __init__(self, parent, ID=wx.ID_ANY, pos=wx.DefaultPosition,
size=wx.DefaultSize, style=0):
"""Constructor"""
wx.ListCtrl.__init__(self, parent, ID, pos, size, style)
listmix.TextEditMixin.__init__(self)
define your listctrl as editable
self.listCtrl = EditableListCtrl(my_panel1, -1, style=wx.LC_REPORT|wx.LC_SINGLE_SEL|wx.LC_VRULES, size=(1145,285))
Then bind for the vetoing of certain items: self.listCtrl.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnVetoItems)
define your veto function
def OnVetoItems(self, event):
if event.m_itemIndex == 0:
event.Veto()
return
Note Columns can be veto'd as well using event.m_col
and checking against the number of the column in the listctrl