Distinguish gtk.Entry icons

I add two icons in gtk.Entry in PyGTK. Icon signals are processed as follows.

def entry_icon_event(self, widget, position, event) 

I am trying to distinguish them between two:

 <enum GTK_ENTRY_ICON_PRIMARY of type GtkEntryIconPosition> <enum GTK_ENTRY_ICON_SECONDARY of type GtkEntryIconPosition> 

How can i do this? I am looking at PyGTK documentation, but there is no GtkEntryIconPosition object or any definition for this listing.

thanks

+4
source share
2 answers

There is a better way to do this:

 def entry_icon_event(self, widget, icon, event): if icon == gtk.ENTRY_ICON_PRIMARY: ... elif icon == gtk.ENTRY_ICON_SECONDARY: ... 
+1
source

Well, since no one gave an answer, I will do what I found. The method for using these icons will look like this:

 def entry_icon_event(self, widget, icon, event): if icon.value_name == "GTK_ENTRY_ICON_PRIMARY": print "First Button" if event.button == 0: print "Left Click": else: print "Right Click" elif icon.value_name == "GTK_ENTRY_ICON_SECONDARY": print "Second Button" if event.button == 0: print "Left Click": else: print "Right Click" 
+1
source

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


All Articles