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:UserserrorAppDataLocalProgramsPythonPython36-32libkinter\__init__.py", line 1699, in __call__
return self.func(*args)
TypeError: printInput() missing 1 required positional argument: 'name'
What am I doing wrong?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…