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

发布于 2024-12-01 14:39:03 字数 129 浏览 5 评论 0原文

如果这看起来是一个微不足道的问题,我很抱歉,但我对使用 GTK Treeview 所需的视图/模型/存储方案的复杂性仍然很陌生。 如何确定当前选定的项目是否是 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.
How to identify if the current selected item is the last item on a gtk.TreeView ?
I don't have children so right now each node is just a row.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挖个坑埋了你 2024-12-08 14:39:03

为此,您必须询问视图选择了哪一行,然后询问模型该行是否是最后一行。就像这样:

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"

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文