I am very new to Python. As a way of learning Tkinter to apply to other projects, I wanted to create something that would update a label to what was in a entry after a button press.
from tkinter import *
top = Tk()
response = StringVar()
response.set("text")
var = StringVar()
var.set("Input")
def updateLabel():
response.set(ent.get())
ent = Entry(top, textvariable = var)
lab = Label(top, textvariable = response)
but = Button(top, text = "Enter", command = updateLabel())
lab.pack(side = LEFT)
ent.pack(side = LEFT)
but.pack(side = RIGHT)
top.mainloop()
It seems like the function is run without me pressing the button because right when the run it, the label already says "Input" like the entry.
Any help would be appreciated. I am sure it is a stupid mistake.
Thanks!