Gtk Switch activates a signal that does not work

I try to use the Gtk.Switch widget in the application, but the “activate” signal does not work with clicks. It works great when using a widget with a keyboard by pressing the reture / space key on it, but clicks do not trigger the “activate” event.

Any idea what needs to be done to register signals for clicks on Gtk.Switch

from gi.repository impoty Gtk, GObject def my_callback(widget, data=None): print 'Event Fired' switch = Gtk.Switch() window = Gtk.Window() window.add(switch) switch.connect('activate', my_callback) window.show_all() GObject.MainLoop().run() 
+6
source share
2 answers

In fact, the best way to connect to a notification :: active event.

+14
source

Well, having examined a couple of days, I asked a question here and found the answer after 5 minutes.

To register a mouse click, instead of the “activate” signal, it is necessary to use the “button-press-event” signal.

May help someone with a similar problem.

GTK needs better documentation.

0
source

Source: https://habr.com/ru/post/895412/


All Articles