[英]Differentiate gtk.Entry icons
I'm adding two icons to a gtk.Entry in PyGTK. 我在PyGTK中的gtk.Entry中添加了两个图标。 The icons signals are handled by the following method
图标信号通过以下方法处理
def entry_icon_event(self, widget, position, event)
I'm trying to differentiate between the two of them: 我试图区分它们两者:
<enum GTK_ENTRY_ICON_PRIMARY of type GtkEntryIconPosition>
<enum GTK_ENTRY_ICON_SECONDARY of type GtkEntryIconPosition>
How can I do this? 我怎样才能做到这一点? I've been digging through the documentation of PyGTK but there's no object GtkEntryIconPosition nor any definition for this enums.
我一直在研究PyGTK的文档,但是没有对象GtkEntryIconPosition或此枚举的任何定义。
Thanks 谢谢
Alright, since no one gave an answer, I'll do with what I actually found. 好吧,因为没有人给出答案,所以我将尽我所能。 A method to use this icons would 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"
There is better way to do it: 有更好的方法:
def entry_icon_event(self, widget, icon, event):
if icon == gtk.ENTRY_ICON_PRIMARY:
...
elif icon == gtk.ENTRY_ICON_SECONDARY:
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.