简体   繁体   English

pygtk - 如何更新gtk.liststore?

[英]pygtk - how update a gtk.liststore?

http://img824.imageshack.us/i/capturadetelag.png/ http://img824.imageshack.us/i/capturadetelag.png/

how update a gtk.liststore? 如何更新gtk.liststore?

i mean get a random number every second on a column just like example, such as a download manager list, i'd like to have a simple example to know how this Liststore works for update the list, because i can't find a effective way to do something like a: 我的意思是在列上获得一个随机数,就像示例一样,例如下载管理器列表,我想有一个简单的例子来了解这个Liststore如何工作以更新列表,因为我找不到有效的做某事的方式:

store.append(list1,list2,list3) store.append(列表1,列表2,项目list3)

store.update(list3,['foobar']). store.update(项目list3,[ 'foobar的'])。

You can iterate over the rows in a list store ( for row in liststore:... ) as well as over the columns (values) in each row ( for col_value in row:... ). 你可以遍历列表中的商店行( for row in liststore:... ),以及在每个行中的列(值)( for col_value in row:... )。

For simple, direct updates: 对于简单,直接的更新:

row_n = 0
col_n = 2
liststore[row_n][col_n] = 'new value'

Otherwise, you can update using a gtk.TreeIter ( row_iter ): 否则,您可以使用gtk.TreeIterrow_iter )进行更新:

liststore.set_value(row_iter, col_n, 'new value')

http://www.pygtk.org/pygtk2reference/class-gtkliststore.html http://www.pygtk.org/pygtk2reference/class-gtkliststore.html

You need to use a gtk.TreeIter , also this has some good information. 你需要使用gtk.TreeIter也有一些很好的信息。

If I were more familiar I could give you an example, I just remember that it's kind of a pain to use the gtk.liststore, but there's not really any better solution 如果我更熟悉我可以给你一个例子,我只记得使用gtk.liststore是一种痛苦,但实际上并没有更好的解决方案

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

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