wxPython - 如何更改 ListCtrl 项目索引?

问题描述

我正在尝试通过复选框的状态更改 ListCtrl 项目的索引。获取复选框的状态并不难,但我找不到更改选中项索引的方法

我的代码如下:

class FilterCheckListCtrl(wx.ListCtrl,CheckListCtrlMixin,ListCtrlAutoWidthMixin):

    def __init__(self,parent):
        wx.ListCtrl.__init__(self,parent,wx.ID_ANY,style=wx.LC_REPORT | 
                wx.SUNKEN_BORDER)
        CheckListCtrlMixin.__init__(self)
        ListCtrlAutoWidthMixin.__init__(self)
        self.SetSize(-1,-1,50)

    def OnCheckItem(self,index,flag):        
        item = self.GetItem(index)
        
        if flag: 
            item.SetId(0)
            self.Update()

作为补充,我还想在未选中时将其重新归入列表(按字母顺序)。有什么好的办法吗?

附言我知道最新版本的 wxPython 更改了复选框行为,但由于 Matplotlib 和 wxPython 4.1.1 的一些问题,我需要保留旧版本!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)