Tkinter error. Unknown option -command for button.(Python 3)

  python, tkinter

I need help in this small code I just made:

from tkinter import *

root = Tk()
e = Entry(root, width=20)
e.grid(row=0, column=0)

def btn_clicked():
    label = Label(root, text=f"Hello {e.get()}!")
    label.grid(row=1, column=0)

button = Button(root, padx=10, text="Click this", COMMAND=btn_clicked)
button.grid(row=0, column=1)
root.mainloop()

Source: Python Questions

One Reply to “Tkinter error. Unknown option -command for button.(Python 3)”

LEAVE A COMMENT