I´m new to python and practicing, and I have now written this piece of coding, but I´m getting an error I do not know how to resolve, could someone help me please?
This is my code:
from tkinter import *
root = Tk()
name = 'donut'
def printInput(event, name):
print("Your name is %s, and you are years old." % (name))
button_1 = Button(root, text="Submit")
button_1.bind("<Button-1>", printInput)
button_1.pack()
root.mainloop()
And when I click on submit, I get this error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\error\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
TypeError: printInput() missing 1 required positional argument: 'name'
What am I doing wrong?
Thanks!