I have code like this
from Tkinter import *
master = Tk()
def oval_mouse_click(event):
print "in oval"
def canvas_mouse_click(event):
print "in canvas"
w = Canvas(master, width = 800, height = 600)
uid = w.create_oval(390, 290, 410, 310, fill='blue')
w.tag_bind(uid, "<Button-1>", lambda x: oval_mouse_click(x))
w.bind("<Button-1>" , canvas_mouse_click)
w.pack()
mainloop()
When I click on Canvas, I have a "in canvas" message in the console. When I click] on Oval, I have two messages “in an oval” and “in a canvas”, but I want to have only the first message. Is there a way to stop the collection of events?
I can accomplish this task with some global flag, but I think there should be a more natural way for Tkl.
source
share