I am trying to have my wxListCtrl
use the native implementation on macos, but I'm only getting the generic implementation.
According to the wxWiki:
Starting with wxWidgets 2.8 (wxMac), wxListCtrl uses a native implementation for report mode, and uses a generic implementation for other modes.
I have already set my wxListCtrl
to LC_REPORT
, but I still get the generic implementation.
What am I doing wrong?
(I'm using Python 3.8.2 on macOS 10.15.4 Catalina, and tested with both stable wxPython 4.0.7 and the latest snapshot build wxPython-4.1.0a1.dev4650+de25f309-cp38-cp38-macosx_10_9_x86_64.whl
)
Minimal example
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import wx
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, 'Example')
panel = wx.Panel(self, wx.ID_ANY)
self.index = 0
self.list_ctrl = wx.ListCtrl(panel, style=wx.LC_REPORT)
self.list_ctrl.InsertColumn(0, 'Title')
btn = wx.Button(panel, label='Add row')
btn.Bind(wx.EVT_BUTTON, self.add_line)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.list_ctrl, 0, wx.ALL|wx.EXPAND, 5)
sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
panel.SetSizer(sizer)
def add_line(self, event):
line = "Row %s" % self.index
self.list_ctrl.InsertItem(self.index, line)
self.index += 1
if __name__ == '__main__':
app = wx.App()
frame = MyForm()
frame.Show()
app.MainLoop()
The native wxListCtrl
implementation under Mac turned out to be too problematic and so was dropped in wx 3. If you can, consider using wxDataViewCtrl
which is native under Mac and generally usable, even if it still has some limitations compared to the generic version due to native API peculiarities.