I'm trying to add an icon to "Gtk.StackSidebar" and I can't (Gtk4 & Python)

            sidebar = Gtk.StackSidebar()
            stack = Gtk.Stack()
            sidebar.set_stack(stack)            
            label = Gtk.Label()
            label.set_label("Page N 01")
            stack.add_named(label, "name");
            stack_page = stack.get_page(label)
            stack_page.set_title("Title")
            icon = "document-new-symbolic"
            stack_page.set_property("icon-name", icon)
            # stack_page.set_icon_name(icon)

GtkStackSidebar cannot show an icon: Add Icon to GtkStackSidebar (#720) · Issues · GNOME / gtk · GitLab

Note that even for GtkStackSwitcher, it shows only the icon, not both the icon and the title: GtkStackSwitcher can't show page icon with label (#4652) · Issues · GNOME / gtk · GitLab

You might find something you can use in libadwaita.

1 Like