Guillaume
Guillaume

Reputation: 2918

python gtk.entry() icon connect: is it possible?

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!

Upvotes: 0

Views: 265

Answers (1)

user4815162342
user4815162342

Reputation: 155026

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)

Upvotes: 1

Related Questions