Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wx.ListCtrl with TextEditMixin - Disable Editing of Selected Cells

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.

like image 361
unddoch Avatar asked Oct 09 '12 18:10

unddoch


1 Answers

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()
like image 160
ErwinP Avatar answered Nov 04 '22 13:11

ErwinP