[英]How do I make wxListCtrl use the native macos implementation?
I am trying to have my wxListCtrl
use the native implementation on macos, but I'm only getting the generic implementation.我试图让我的
wxListCtrl
在 macos 上使用本机实现,但我只得到通用实现。
According to the wxWiki :根据wxWiki :
Starting with wxWidgets 2.8 (wxMac), wxListCtrl uses a native implementation for report mode, and uses a generic implementation for other modes.
从 wxWidgets 2.8 (wxMac) 开始,wxListCtrl 使用原生实现报告模式,其他模式使用通用实现。
I have already set my wxListCtrl
to LC_REPORT
, but I still get the generic implementation.我已经将
wxListCtrl
设置为LC_REPORT
,但我仍然得到了通用实现。
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
) (我在 macOS 10.15.4 Catalina 上使用 Python 3.8.2,并测试了稳定的 wxPython 4.0.7 和最新的快照构建
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()
Mac 下原生的wxListCtrl
实现被证明是有太多问题,因此在 wx 3 中被删除。 如果可以,请考虑使用wxDataViewCtrl
,它是 Mac 下原生的并且通常可用,即使它与通用版本相比仍然有一些限制,因为原生 API 特性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.