Why does the pygtk callback on a clicked ToolButton executed twice when clicked once
I've got a simple callback function which switches the label of a PyGTK button:
def langSelectHandler(self, widget, callback_data=None):
if self.lang == "fr":
self.lang = "de"
print "changed to de"
widget.set_label("Deutsch")
else:
self.lang = "fr"
print "changed to fr"
widget.set_label("Français")
开发者_运维知识库The button is connected like this:
self.langSelect.connect("clicked", self.langSelectHandler)
(I verified the duplicate call using random numbers generated each call, they were different) My problem is, that the callback gets executed twice, and therefore switches back to its old value, so no change is visible. Why the hell is that the case and how can this be prevented?
Thanks, Julian
as pointed out in my comment (see the 2nd entry below the post), I made a connect via the code as well as via glade which lead to the 2 calls. If you ran into a similar or same problem just check that.
精彩评论