[英]How to get the list of selected rows of a Gtk.TreeView as int?
I found that I can get the selected rows like this我发现我可以像这样获得选定的行
model, iters = treeview.get_selection().get_selected()
or like this或者像这样
model, paths = treeview.get_selection().get_selected_rows()
but iters
and paths
are not lists of int
.但
iters
和paths
不是int
列表。
Is it possible to convert a Gtk.TreeIter
or a Gtk.TreePath
to int
?是否可以将
Gtk.TreeIter
或Gtk.TreePath
转换为int
?
You can use :您可以使用 :
path, _ = treeview.get_cursor()路径,_ = treeview.get_cursor()
path is a 'TreePath' and not 'int'路径是“TreePath”而不是“int”
indices = path.get_indices()指数 = path.get_indices()
indices is a list of the row numbers : [2 , ...]索引是行号列表: [2 , ...]
indices[0] is the first row number (as integer !) of the selection索引 [0]是选择的第一行号(作为整数!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.