如何获取GTK.Stack中可见child的索引
How to get the index of visible child in GTK.Stack
是否可以在 Gtk.Stack 中获取 visible 的索引?
示例:
>>> 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
这可能吗?
Stack 文档包括 position
子 属性:
child = stack.get_visible_child()
if child is not None:
position = stack.child_get_property(child, "position")
是否可以在 Gtk.Stack 中获取 visible 的索引?
示例:
>>> 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
这可能吗?
Stack 文档包括 position
子 属性:
child = stack.get_visible_child()
if child is not None:
position = stack.child_get_property(child, "position")