I have an issue when editing cells in a wxListCtrl using the TextEditMixin. The first time editing a cell, the selected text highlights fine. However, on subsequent attempts to edit cells the selected text does not highlight.
The text is apparently selected as it can be moved, deleted, replaced; it's just that the highlighting feedback does not appear on second and subsequent cell edits.
Python: 3.7; wxWidgets: 4.0.7post2; OS: Windows 10 pro and LTSC 1809
Thoughts?
Here is code that can be run to demonstrate the problem:
# example showing TextEditMixin issue: not highlighting selecting text
import wx
import wx.lib.mixins.listctrl as listmix
class ListCtrlCustom(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)
class ListCtrlPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
sizer = wx.BoxSizer(wx.VERTICAL)
# create the list with ability to edit cells
self.list_ctrl = ListCtrlCustom(self, size=(-1, 100), style=wx.LC_REPORT | wx.BORDER_SUNKEN)
#self.list_ctrl = wx.ListCtrl(self, style=wx.LC_EDIT_LABELS | wx.LC_REPORT)
self.list_ctrl.InsertColumn(0, "col 1", width=100)
self.list_ctrl.InsertColumn(1, "col 2", width=100)
# add rows to the list
for idx in range(0, 2):
colOneText = 'col1 value: ' + str(idx)
colTwoText = 'col2 value: ' + str(idx)
self.list_ctrl.InsertItem(idx, colOneText)
self.list_ctrl.SetItem(idx, 1, colTwoText)
sizer.Add(self.list_ctrl, 0, wx.ALL | wx.EXPAND, 5)
self.SetSizer(sizer)
class ListCtrlFrame(wx.Frame, listmix.TextEditMixin):
def __init__(self):
super().__init__(parent=None, title='list ctrl test')
self.panel = ListCtrlPanel(self)
self.Show()
if __name__ == '__main__':
app = wx.App()
frame = ListCtrlFrame()
app.MainLoop()