May-10-2021, 08:16 PM
Hello there.
I am attempting to bind the left mouse button to a grid of tkinter rectangles. I am trying to execute function clicked() when someone clock on a tkitner rectangle. I am looping their creation to create a grid. However, when I click the rectangle, the code is not executed.
Grid Creation Loop:
I am attempting to bind the left mouse button to a grid of tkinter rectangles. I am trying to execute function clicked() when someone clock on a tkitner rectangle. I am looping their creation to create a grid. However, when I click the rectangle, the code is not executed.
Grid Creation Loop:
for x in range(0, wid, 60): for y in range(0, leng, 60): rectangle = drawCanv.create_rectangle(x, y, x+60, y+60, outline='black') drawCanv.tag_bind("rectangle","<Button-1>",lambda: clicked)Function (just testing. will replace with other code):
def clicked(): print("You Clicked Me")