使用 append 将复选框添加到 Ultimatelistctrl
Adding Checkbox to Ultimatelistctrl with append
所以我有一个 ultimatelistctrl,看起来像这样:
self.FileList=ULC.UltimateListCtrl(self.panel,size=(self.width,400),agwStyle=wx.LC_REPORT
|ULC.ULC_USER_ROW_HEIGHT|ULC.ULC_SINGLE_SEL|ULC.ULC_BORDER_SELECT|ULC.ULC_AUTO_TOGGLE_CHILD)
self.FileList.SetUserLineHeight(30)
self.FileList.SetHeaderHeight(40)
self.FileList.SetFont(self.ListText)
#self.FileList.Bind(wx.EVT_LIST_ITEM_FOCUSED,self.OnItemSelect)
#First Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Select"
info._kind=1
self.FileList.InsertColumnInfo(0,info)
self.FileList.SetColumnWidth(0,70)
#Second Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Name"
self.FileList.InsertColumnInfo(1,info)
self.FileList.SetColumnWidth(1,400)
#Third Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Database"
self.FileList.InsertColumnInfo(2,info)
self.FileList.SetColumnWidth(2,150)
#fourth Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Size"
self.FileList.InsertColumnInfo(3,info)
self.FileList.SetColumnWidth(3,150)
#Fifth Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Status"
self.FileList.InsertColumnInfo(4,info)
self.FileList.SetColumnWidth(4,110)
我现在想使用 append 向列表中添加数据。
self.FileList.Append([wx.CheckBox(self.FileList,-1),listOfFiles[i],database,stringSize,""])
但是我收到错误
TypeError: argument of type 'CheckBox' is not iterable
我知道我可以用
创建一个项目
self.FileList.InsertStringItem(i,"",it_kind=1)
然后复选框就在那里,一切正常。但是我必须添加一行来插入每个字符串,而且我还必须跟踪我刚刚创建的项目。
但是我想使用附加功能,我觉得我只是错误地调用了复选框按钮。
所以我找到了一个解决方法,所以我仍然可以使用追加。但我仍然非常希望它知道在 append 中放入什么以获得复选框。
现在我只是在追加之后添加
self.FileList.SetItemKind(self.FileList.GetItemCount()-1,0,kind=1)
但这有点不是我所关注的真正解决方案。
所以我有一个 ultimatelistctrl,看起来像这样:
self.FileList=ULC.UltimateListCtrl(self.panel,size=(self.width,400),agwStyle=wx.LC_REPORT
|ULC.ULC_USER_ROW_HEIGHT|ULC.ULC_SINGLE_SEL|ULC.ULC_BORDER_SELECT|ULC.ULC_AUTO_TOGGLE_CHILD)
self.FileList.SetUserLineHeight(30)
self.FileList.SetHeaderHeight(40)
self.FileList.SetFont(self.ListText)
#self.FileList.Bind(wx.EVT_LIST_ITEM_FOCUSED,self.OnItemSelect)
#First Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Select"
info._kind=1
self.FileList.InsertColumnInfo(0,info)
self.FileList.SetColumnWidth(0,70)
#Second Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Name"
self.FileList.InsertColumnInfo(1,info)
self.FileList.SetColumnWidth(1,400)
#Third Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Database"
self.FileList.InsertColumnInfo(2,info)
self.FileList.SetColumnWidth(2,150)
#fourth Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Size"
self.FileList.InsertColumnInfo(3,info)
self.FileList.SetColumnWidth(3,150)
#Fifth Column
info=ULC.UltimateListItem()
info._mask=wx.LIST_MASK_TEXT|wx.LIST_MASK_IMAGE|wx.LIST_MASK_FORMAT|ULC.ULC_MASK_CHECK
info._image=[]
info._format=0
info._text="Status"
self.FileList.InsertColumnInfo(4,info)
self.FileList.SetColumnWidth(4,110)
我现在想使用 append 向列表中添加数据。
self.FileList.Append([wx.CheckBox(self.FileList,-1),listOfFiles[i],database,stringSize,""])
但是我收到错误
TypeError: argument of type 'CheckBox' is not iterable
我知道我可以用
创建一个项目self.FileList.InsertStringItem(i,"",it_kind=1)
然后复选框就在那里,一切正常。但是我必须添加一行来插入每个字符串,而且我还必须跟踪我刚刚创建的项目。
但是我想使用附加功能,我觉得我只是错误地调用了复选框按钮。
所以我找到了一个解决方法,所以我仍然可以使用追加。但我仍然非常希望它知道在 append 中放入什么以获得复选框。
现在我只是在追加之后添加
self.FileList.SetItemKind(self.FileList.GetItemCount()-1,0,kind=1)
但这有点不是我所关注的真正解决方案。