I have this code:
def userChoice():
text = "Clicked"
row1 = Button(root, text=" ", command = "userChoice")
row1.config(height="6", width="10")
row1.grid(row=0, column=0)
I want to make it so that when the user clicks the button the text is changed. I am not sure how I would do this I ran this code and when the button is clicked nothing happens? I know this is a very simple question but just cannot figure out how to do it. I have been trying for the pas hour or so.
You can use row1["text"] to set new value:
from Tkinter import *
root = Tk()
def userChoice():
row1["text"] = "CLICKED!"
row1 = Button(root, text=" ", command = userChoice)
row1.config(height="6", width="10")
row1.grid(row=0, column=0)
mainloop()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With