如何将行及其对应的数据附加到 ListCtrl 中。我刚刚完成了如何使用 TreeCtrl(比 ListCtrl 相对容易),它向我展示了匹配单个 GUI 对象和数据的清晰用法。但 ListCtrl 没有。
- 如何使用相应的数据附加或插入单行。
- 如何访问行及其数据
- 我如何操作它们(编辑数据/行,删除数据/行)
你能解释一下它们的概要吗?谢谢你。我知道我的问题很简单,我可以从 doc 那里得到一些信息。我阅读了文档,但我仍然不知道
我知道 wxPython 文档很迟钝并且没有提供太多帮助,下面是一些快速提示,我在评论中添加了解释:
# create new list control
listctrl = wx.dataview.DataViewListCtrl( my_panel, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.dataview.DV_SINGLE )
# setup listctrl columns
listctrl.AppendTextColumn('first name', width=220) # normal text column
listctrl.AppendBitmapColumn('my images', 0, width=35) # you can add images in this col
listctrl.AppendProgressColumn('Progress', align=wx.ALIGN_CENTER) # a progress bar
listctrl.SetRowHeight(30) # define all rows height
# add data, note myList is a list or tuple contains the exact type of data for each columns and same length as col numbers
listctrl.AppendItem(myList)
# to modify an entry "a single cell located at row x col"
listctrl.SetValue(myNewValue, row, column)