复选框问题在虚拟模式下使用UltimateListCtrl以wxPython显示数据

复选框问题在虚拟模式下使用UltimateListCtrl以wxPython显示数据,python,checkbox,wxpython,Python,Checkbox,Wxpython,好的,请注意,我有一个python应用程序,它显示数据库查询的结果,何时可以返回100行,或者100000+,所以我使用UltimateListCtrl作为wxPython库的一部分, 我可以让它显示数据,没有问题,但其中一个要求是,在某个列的数据的每一行上都有一个复选框,以便用户可以选择或不选择,但这就是我遇到的问题,我知道您可以将wxWidgets添加到UltimateListCtrl行中,但在虚拟模式下,当我滚动数据时,不确定如何做到这一点 下面是我的代码 任何帮助,再见,举个例子,都是受

好的,请注意,我有一个python应用程序,它显示数据库查询的结果,何时可以返回100行,或者100000+,所以我使用UltimateListCtrl作为wxPython库的一部分, 我可以让它显示数据,没有问题,但其中一个要求是,在某个列的数据的每一行上都有一个复选框,以便用户可以选择或不选择,但这就是我遇到的问题,我知道您可以将wxWidgets添加到UltimateListCtrl行中,但在虚拟模式下,当我滚动数据时,不确定如何做到这一点 下面是我的代码

任何帮助,再见,举个例子,都是受欢迎的,因为这几周来一直在帮我的忙

导入wx 从wx.lib.agw导入ultimatelistctrl作为ULC

类clsVCList00(ULC.UltimateListCtrl):

def __init__(self, parent):
    #
    self.cols = ["Select","Index","Research Key","Results"]   
    self.hdr_index = 0
    #
    ULC.UltimateListCtrl.__init__(self, parent , -1, agwStyle=wx.LC_REPORT|wx.LC_VIRTUAL|wx.LC_VRULES)
    #
    for hdr in self.cols:
        res = self.InsertColumn(self.hdr_index, hdr, width=150)
        if hdr == "Select":
           chk = ULC.UltimateListItem()
           chk._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_CHECK
           chk._image = []
           chk._format = wx.LIST_FORMAT_LEFT
           chk._text = "Select"
           chk._kind = 1      
           self.SetColumn(res,chk)
        self.hdr_index = self.hdr_index + 1 
    #
    #    
    self.attr1 = ULC.UltimateListItemAttr()
    self.attr1.SetBackgroundColour(wx.NamedColour("yellow"))
    self.attr2 = ULC.UltimateListItemAttr()
    self.attr2.SetBackgroundColour(wx.NamedColour("light blue"))
    self.SetItemCount(10000)


def OnGetItemAttr(self, item):
    if item % 3 == 1:
        return self.attr1
    elif item % 3 == 2:
        return self.attr2
    else:
        return None

def OnGetItemImage(self, item):
    return []

def OnGetItemText(self, item, col):
    return "Item %d, column %d" % (item, col)

def OnGetItemToolTip(self, item, col):
    if item == 0:
        return "Tooltip: Item %d, column %d" % (item, col)
    return None

def OnGetItemTextColour(self, item, col):
    if item == 0 and col == 0:
        return wx.Colour(255,0,0)
    elif item == 0 and col == 1:
        return wx.Colour(0,255,0)
    elif item == 0 and col == 2:
        return wx.Colour(0,0,255)
    else:
        return None