【问题标题】:How to get the index of visible child in GTK.Stack如何在 GTK.Stack 中获取可见子项的索引
【发布时间】:2016-10-28 14:19:07
【问题描述】:

是否可以获取 Gtk.Stack 中可见的索引?

例子:

>>> stack = Gtk.Stack()
>>> stack.add_named(any_widget1, 'any_widget1') # Index 0
>>> stack.add_named(any_widget2, 'any_widget2') # Index 1
>>> stack.add_named(any_widget3, 'any_widget3') # Index 2
>>>
>>> stack.get_visible_child_index()
0

这可能吗?

【问题讨论】:

    标签: python gtk pygobject


    【解决方案1】:

    Stack 文档包括 position 子属性:

    child = stack.get_visible_child()
    if child is not None:
        position = stack.child_get_property(child, "position")
    

    【讨论】:

    • 我总是忘记查看子属性。
    猜你喜欢
    • 2015-09-11
    • 1970-01-01
    • 2011-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-13
    • 2021-06-17
    • 2018-02-02
    相关资源
    最近更新 更多