Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect the change of a GtkStack or GtkStackSwitcher

Tags:

python

gtk

gtk3

What I'm trying to-do is detect when a user changes the visible child in a GtkStack.

I'm using a GtkStackSwitcher as a visible way to display buttons as per this design:

pic

Thus - when a person clicks/toggles one of those buttons I want to perform some processing.

Which event should I connect to achieve this?

I've looked at both Gtk.Stack and Gtk.StackSwitcher but I dont see any obvious signals. Any thoughts on the best way to proceed?

These don't appear to be standard buttons - so a 'clicked' event I dont think applies in this scenario.

I'm using Ubuntu 14.04 Gtk+3.10, python3

like image 696
fossfreedom Avatar asked Mar 21 '15 12:03

fossfreedom


1 Answers

visible-child is the property you are looking for. Use the notify signal to get notified of changes:

def vc_changed(stack, gparamstring):
    print("visible child changed")

my_stack.connect("notify::visible-child", vc_changed)
like image 185
Jussi Kukkonen Avatar answered Nov 17 '22 14:11

Jussi Kukkonen