题
我添加两个图标在PyGTK中一个gtk.Entry。的图标的信号由下面的方法来处理
def entry_icon_event(self, widget, position, event)
我想要他们两个之间进行区分:
<enum GTK_ENTRY_ICON_PRIMARY of type GtkEntryIconPosition>
<enum GTK_ENTRY_ICON_SECONDARY of type GtkEntryIconPosition>
我怎样才能做到这一点?我已经挖通的PyGTK的文档,但没有对象GtkEntryIconPosition也不是为这个枚举任何定义。
由于
解决方案
有更好的方式来做到这一点:
def entry_icon_event(self, widget, icon, event):
if icon == gtk.ENTRY_ICON_PRIMARY:
...
elif icon == gtk.ENTRY_ICON_SECONDARY:
...
其他提示
好了,因为没有人给一个答案,我会与我居然发现做。以使用该图标的方法是这样的:
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"
不隶属于 StackOverflow