开发者

Gtk Switch activate signal not firing

开发者 https://www.devze.com 2023-03-29 01:11 出处:网络
I\'m trying to use a Gtk.Switch widget in an app but \"activate\" signal is not firing by clicks. It works fine when using the widget with keyboard by hitting reture/space key on it but clicks don\'t

I'm trying to use a Gtk.Switch widget in an app but "activate" signal is not firing by clicks. It works fine when using the widget with keyboard by hitting reture/space key on it but clicks don't fire the "activate" event.

Any Idea what is to be done in order to register signals for clicks on Gtk.Switch

from gi.repository impoty Gtk, GObject

def my_callback(widget, data=None):
    print 'Event Fired'

switch = Gt开发者_JAVA技巧k.Switch()
window = Gtk.Window()
window.add(switch)
switch.connect('activate', my_callback)
window.show_all()
GObject.MainLoop().run()


Actually, a better way is connect to the notify::active event.


Ok, after looking around for a couple of days I asked the question here and found the answer 5 minutes later.

To register mouse click, 'button-press-event' signal has to be used instead of 'activate' signal.

Might help someone with a similar problem.

GTK needs better documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消