This code is a tutorial from youtube. The given code is supposed to print right on the right click of the mouse on the console and same for the left click but it is not doing so. I think the problem is with the bind function.
I am using python 3.7 which already have tkinter package in it, what can I do to make it work, thank you very much.
from tkinter import *
root = Tk()
def leftclick(event):
print("left")
def rightclick(event):
print("right")
frame = Frame(root, width=300, height=300)
frame.bind("button-1", leftclick)
frame.bind("button-2", rightclick)
frame.pack()
root.mainloop()
I expect the program to print 'left' in the console on the left click of the mouse inside the tk window and same for right click
'<Button-1>'and'<Button-2>'.