2016-10-28 75 views
1

可能得到Gtk.Stack中可見的索引嗎?如何獲取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 

這是可能的?

回答

2

堆棧文檔包括position子屬性:

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

我總是忘了看孩子的性能。 –

相關問題