Gtk.StackSidebar
Gtk.StackSidebar — An automatic sidebar widget
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Widget
╰── Gtk.Container
╰── Gtk.Bin
╰── Gtk.StackSidebar
Functions:
Description:
A Gtk.StackSidebar
enables you to quickly and easily provide a consistent "sidebar" object for your user interface.
In order to use a Gtk.StackSidebar
, you simply use a GtkStack to organize your UI flow, and add the sidebar to your sidebar area. You can use Gtk.StackSidebar::set_stack()
to connect the Gtk.StackSidebar
to the Gtk.Stack.
Function Details:
new()
new () -> Gtk.Widget
Creates a new sidebar.
Returns: the new Gtk.StackSidebar
Since: 3.16
set_stack()
set_stack (self, stack:Gtk.Stack)
Set the Gtk.Stack
associated with this Gtk.Stack
Sidebar.
The sidebar widget will automatically update according to the order(packing) and items within the given Gtk.Stack
.
- Since: 3.16
get_stack()
get_stack (self) -> Gtk.Stack
Retrieves the stack.See Gtk.StackSidebar:set_stack()
.
Returns: the associated
Gtk.Stack
orNone
if none has been set explicitly.Since: 3.16
Example:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class StackSidebar(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self)
self.set_default_size(400, 300)
self.connect("destroy", Gtk.main_quit)
grid = Gtk.Grid()
self.add(grid)
stack = Gtk.Stack()
stack.set_hexpand(True)
stack.set_vexpand(True)
grid.attach(stack, 1, 0, 1, 1)
stacksidebar = Gtk.StackSidebar()
stacksidebar.set_stack(stack)
grid.attach(stacksidebar, 0, 0, 1, 1)
for page in range(1, 4):
label = Gtk.Label("Stack Content on Page %i" % (page))
name = "label%i" % page
title = "Page %i" % page
stack.add_titled(label, name, title)
window = StackSidebar()
window.show_all()
Gtk.main()