I try to create a custom Gtk.Image that handles the "clicked" signal but when I try to emit a signal from the custom Gtk.Image ,but can't figure out why doesn't the signal emit when there is a button press event.
class WindowButton(Gtk.Image): gtype_name = "WindowButton"
__gsignals__ = {
"clicked" : (GObject.SIGNAL_ACTION,None,(Gdk.Event,))
}
def __init__(self,*args,**kwargs):
Gtk.Image.__init__(self,*args,**kwargs)
self.set_from_stock(Gtk.STOCK_OK,Gtk.IconSize.SMALL_TOOLBAR)
self.event = Gdk.Event.new(Gdk.EventType.BUTTON_PRESS)
self.emit("button-press-event",self.event)
self.connect("button-press-event",self.on_button_press_event)
self.connect("clicked",self.do_clicked)
def on_button_press_event(self,event):
print(ButtonPressEvent)
print(event)
self.emit("clicked",self.event)
def do_clicked(self,event):
print('clicked')
print(event)
GtkImage has no signal like 'clicked'. Put your GtkImage within an EventBox and hook your signals to the EventBox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With