简体   繁体   English

如何识别当前选定的行是否是gtk.TreeView的最后一行?

[英]How to identify if the current selected row is the last on a gtk.TreeView?

I am sorry if this looks a trivial question but I am still new to the complexity of the View/model/store scheme require to use the GTK Treeview. 很抱歉,如果这看起来很琐碎,但是对于使用GTK Treeview的视图/模型/存储方案的复杂性,我还是陌生的。 How to identify if the current selected item is the last item on a gtk.TreeView ? 如何识别当前所选项目是否是gtk.TreeView上的最后一个项目? I don't have children so right now each node is just a row. 我没有孩子,所以现在每个节点都只是一行。

To do that, you have to ask the view what row is selected, then ask the model whether that row is the last one. 为此,您必须询问视图选择了哪一行,然后询问模型该行是否为最后一行。 Like so: 像这样:

selection = view.get_selection()
model, iter = selection.get_selected()
if iter is None:
    print "Nothing selected"
else:
    if model.iter_next(iter) is not None:
        print "Selected item was not last"
    else:
        print "Selected item was last"

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

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