简体   繁体   English

如何在wxpython上使用`ListCtrl`

[英]How to use `ListCtrl` on wxpython

How can I append row and it's corresponding data into ListCtrl. 如何将行及其相应的数据附加到ListCtrl中。 I've just finished how to use TreeCtrl(Relatively easier than ListCtrl), it shows me a clear usage of matching single GUI object and data. 我刚刚完成了如何使用TreeCtrl(比ListCtrl相对容易),它向我展示了匹配单个GUI对象和数据的明确用法。 But ListCtrl dose not. 但ListCtrl没有。

  1. How can I append or insert single row with it's corresponding data. 如何使用相应的数据追加或插入单行。
  2. How can I access row and it's data 如何访问行及其数据
  3. How can I manipulated them (Editing data/row, Deleting data/row) 我该如何操作它们(编辑数据/行,删除数据/行)

Can you explain summary of them? 你能解释一下这些摘要吗? Thank you. 谢谢。 I know my question is so simple and I can get about this from doc somewhat. 我知道我的问题很简单,我可以从某种程度上解决这个问题。 I read docs, but still I got no clue 我阅读了文档,但我仍然不知道

I know that wxPython docs are retarded and gives no much help, here is some quick tips below, i added explanations in comments: 我知道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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM