pygtk - 有关 ListViews 的问题:更新/附加值
我对使用 ListView
和 ListStore
等有一些常见问题。
我的程序包含一个 ToDo 列表,它是 Task
列表 -对象。 Task
对象有两个属性:title
和 progress
。现在我想在 ListView
中显示这些待办事项列表,在第一列中显示任务的 title
,在第二列中显示progress
。
所以我可以创建一个带有两个TreeViewColumn
的ListView
,每个都有一个CellRendererText
和一个数据函数(set_cell_data_func
)设置适当的列文本(Task
-对象的title
-或progress
-属性)。
当然,任务的进度
可以在另一个线程中随着时间的推移而改变。因此,应该更新进度单元格以显示新值。但是我如何告诉 ListView
Task
对象已更改并且视图应该更新?
跟踪列表更改的最简单方法是什么?例如,一个新的Task
对象被添加到ToDo列表中。我是否需要自己将新添加的 Task
对象附加到 ListStore
还是有更简单的方法? ...因为我有两个列表:原始的待办事项列表和 ListStore
这似乎是不必要的。
那么在 ListView
中显示我的待办事项列表的最佳/最简单/最简单的方法是什么? :-)
最好的问候,
Biggie
i have some general questions about using ListView
s and ListStore
s etc..
My program contains a ToDo-list which is a list of Task
-objects. A Task
-object has two attributes: title
and progress
. Now i want to display these ToDo-list in a ListView
showing the title
of the task in the first column and the progress
in the second column.
So i could create a ListView
with two TreeViewColumn
s, each with a CellRendererText
and a data function (set_cell_data_func
) to set the appropriate column-text (title
- or progress
-attribute of the Task
-object).
Of course, the progress
of a task can change over time in another thread. So the progress-cells should be updated to show the new value. But how can i tell the ListView
that the Task
-object has changed and the view should be updated?
And what is the simplest way to keep track of list-changes? For example a new Task
-object is added to the ToDo-list. Do i need to append the new added Task
-object to the ListStore
by myself or is there an easier way? ... because i would have two lists: the original ToDo-list and the ListStore
which seems to be unnecessary.
So what is the best/simplest/easiest way to show my ToDo-list in a ListView
? :-)
Best regards,
Biggie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我宁愿使用 gtk.ListStore 作为您的列表模型和主要\仅“TODO 列表”数据源,一旦您更改模型中的值,您的列表视图内容应该更新,如下所示:
如果您需要跟踪您的更改模型字段,连接到“row-changed ”信号:
希望这有帮助,问候
I would rather use gtk.ListStore as your list model and primary\only "TODO list" data source , once you change values in the model, your list view content should be updated, smth like this:
if you need to track changes for your model fields, connect to the "row-changed" signal:
hope this helps, regards