I am writing a GUI application in python with tkinter. I have a function that is used in the button widget to change the text of an entry widget. When I run the python script, the entry widget updates with the text before I click the button widget. Can anyone tell me why it is doing this and how to fix it?
Please see my code below:
import tkinter as tk
def changeText(TKEntry, text):
TKEntry.insert(0, text)
def buildMain():
window = tk.Tk()
window.title("Login")
window.geometry("200x110")
lblLogin = tk.Label(window, text="Log In")
lblLogin.place(x=85,y=0)
lblUser = tk.Label(window, text="Username:")
lblUser.place(x=0,y=30)
edtUser = tk.Entry()
edtUser.place(x=70,y=30)
lblPass = tk.Label(window, text="Password:")
lblPass.place(x=0,y=50)
edtPass = tk.Entry()
edtPass.place(x=70,y=50)
btnLogin = tk.Button(text="Log In", command= changeText(edtUser,"Text Changed"))
btnLogin.place(x=150, y=80)
window.mainloop()
buildMain()