[pygtk] Get value of selected treeview rows
John Finlay
finlay at moeraki.com
Tue Dec 14 03:12:30 WST 2004
Marcus Habermehl wrote:
>Hello.
>
>I want to get the values of selected (multiple) rows in a gtk.TreeView.
>
>But I doesn't understand how I can do this.
>
>If I can only select one row, I get the value with
>
>entry1, entry2 = treeview1.get_selection().get_selected()
>entry = entry1.get_value(entry2, 0)
>
>>From there I thought that this is correct.
>
>select1, select2 = treeselection1.get_selected_rows()
>for item in select2[0]:
> print select1.get_value(item, 0)
>
>But I become this error.
>
>Traceback (most recent call last):
> File "./gpkgtool.py", line 116, in Rm
> print select1.get_value(item, 0)
>TypeError: iter must be a GtkTreeIter
>
>How can I get the values, now?
>
>
You can get a TreeIter for each path like:
select1.get_value(select1.get_iter(item), 0)
or directly use:
select1[item][0]
See:
http://www.pygtk.org/pygtk2tutorial/sec-TreeModelInterface.html#sec-PythonProtocolSupport
for more info on the latter form.
John
More information about the pygtk
mailing list