0

I'm using in Pygtk 2.7 a gtk.Entry. I have set an Icon on this, I would like to know if it's possible to connect the icon to a fonction. My construction is like this:

    def info(self, a, b):
        print "INFOS & HELP"
    def __init__(self):
        window = gtk.window(gtk.WINDOW_TOPLEVEL)
        #[...]     
        self.champ_adr_canal = gtk.Entry()
        self.champ_adr_canal.connect("activate", self.download, self.champ_adr_canal)
        self.champ_adr_canal.set_text("")
        boite_adr.pack_start(self.champ_adr_canal, False, True, 0)
        self.champ_adr_canal.set_icon_from_stock(1, gtk.STOCK_DIALOG_QUESTION) # the icon is here
        ### this line is a pseudo code ####
        self.champ_adr_canal.connect("clicked", self.info, "bouton info") # how can I do this? 
        ###                            ####
        self.champ_adr_canal.show()

Thanks!

Guillaume
  • 2,752
  • 5
  • 27
  • 42

1 Answers1

1

According to the documentation, you need to make the icon activatable and connect to the icon-press or icon-release signal:

self.champ_adr_canal.set_icon_activatable(1, True)
self.champ_adr_canal.connect("icon-release", self.info)
user4815162342
  • 141,790
  • 18
  • 296
  • 355