Reputation: 6004
Is there any way to disable the editing of specific cells by the user when using ListCtrl
with TextEditMixin
?
I guess there's some way that Vetos the editing event, however I can't find it.
Upvotes: 8
Views: 2524
Reputation: 402
In wxPython version 4.0.0 the line:
if event.m_col == 1
does not work. Use
if event.GetColumn() == 1
instead.
Upvotes: 2
Reputation: 33081
As I recall, you have to bind to EVT_LIST_BEGIN_LABEL_EDIT. Then in your event handler you just check what column you're in and if you're in a column that you want to be editable, then you do "event.Allow()", otherwise you veto.
Upvotes: 1
Reputation: 412
Event wx.EVT_LIST_BEGIN_LABEL_EDIT:
class EditableListCtrl(wx.ListCtrl, 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.TextEditMixin.__init__(self)
self.Bind(wx.EVT_LIST_BEGIN_LABEL_EDIT, self.OnBeginLabelEdit)
def OnBeginLabelEdit(self, event):
if event.m_col == 1:
event.Veto()
else:
event.Skip()
Upvotes: 12