gtkgtk3pygobject

How do I set the position of a item in a Gtk Stack?


I need to be able to designate the order which stacks go into a Gtk Stack. For example if I have a stack with the pages Welcome and Editor already added how do I add a Settings stack in between the other two?

Is there something simple I'm missinglike inserting items to a Gtk.Listbox? I'm using python and pygobject.


Solution

  • Unfortunately GTK documentation can be tricky to follow. And most pygtk references don't reflect the object nature of widgets. From my experience to find something it's easiest to start with Gnome developer and then look around how it translates to the bind library (pygtk, gtkmm, etc) you are using.

    In GtkStack child properties you can see that there is a property for position of a child in GtkStack.
    Then, in GtkContainer you can find that in order to set child properties, you need to use the function from GtkContainer, instead of one directly in GtkStack. So it should be something like (untested):
    stack_widget.child_set_property(settings_widget, 'position', 1)