Reset the define in a button by pressing another define in tkinter?

Viewed 41

I'm trying to create a program for the keyboard bind by resetting the defined functions of a menu button.

def img1():
    def motion(e):
        imgopen=ImageTk.PhotoImage(Image.open("first"))
        imglbl=canvas.creat_image(e.x, e.y, image=imgopen)
    def release(e):
        imgopen=ImageTk.PhotoImage(Image.open("first"))
        imglbl=canvas.create_image(e.x, e.y, image=imgopen)
    canvas.bind("<B1-Motion>", motion)
    canvas.bind("<ButtonRelease-1>", release)
def line():
    canvas.bind("<B1-Motion>", motion)
    canvas.bind("<ButtonRelease-1>", release)
    canvas.bind("<ButtonPress-1>", press)
def press(e):
    old["x"] = e.x
    old["y"] = e.y
    line.append(canvas.create_line(old["x"],old["y"], fill=black))
def motion(e):
    old["x"] = e.x
    old["x"] = e.x
    canvas.old(line[-1],old["x"],old["y"])
def release(1):
    ple=[]
    ple.append(old["x"]);ple.append(old["y"])
    final.append(ple)

imgbtn = Button(root, text="Image", command=img1).pack()
linebtn = Button(root, text="Line", command=line).pack()

This is my sample code. If I click the image button I can drag the image that I put and when I click the line button if I press, drag, release my button the image still can be moved with the line. I want to reset my define by using a keyboard bind which is the escape.

0 Answers
Related