如何在 wxpython 上使用 `ListCtrl`

How to use `ListCtrl` on wxpython

如何将行及其对应的数据附加到 ListCtrl 中。 我刚刚完成了如何使用 TreeCtrl(相对于 ListCtrl 更容易),它向我展示了匹配单个 GUI 对象和数据的清晰用法。但是ListCtrl没有。

  1. 如何使用相应的数据追加或插入单行。
  2. 如何访问行及其数据
  3. 我如何操纵它们(编辑 data/row、删除 data/row)

你能解释一下它们的概要吗?谢谢你。 我知道我的问题很简单,我可以从医生那里得到一些帮助。 我阅读了文档,但仍然一无所知

我知道 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)