0

After I have created a button or any other object as such, how can I change its properties later on in the code? For example:

b = Button(root, text="button")

How do I change the text in b or add a command for b. I actually want to change the colour of b when it is clicked.

1
  • You can change properties of a Button widget using config modifier. Commented Feb 24, 2016 at 15:44

1 Answer 1

3

To change the attributes of a widget after its initialization, use config.

b.config(text="new text goes here")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.