I am trying to create a button that changes a labels text, I feel like it should work fine, but the function that I assigned to the buttons command gets called before I even press the button, why is this happening and is there anything I can do to fix it?
Here is my code:
import tkinter as tk
def changeLabelText(my_label, new_text):
my_label.config(text = new_text)
root = tk.Tk()
root.geometry("500x500")
label = tk.Label(root, text = "Old Text", font = ("font", 30))
label.grid(row = 0)
changeTextButton = tk.Button(root, text = "Click to change label text",
command = changeLabelText(label, "New Text"))
changeTextButton.grid(row = 1)
tk.mainloop()