How to reset background color of a python tkinter button?

I use the code:

def ToGray(self, to_gray):
    to_gray['bg'], to_gray['fg'] = "SystemButtonFace", "Black"

Then you can get the default button or label.


You can ask the button what color it is before you change it. Save the color, and then restore it later:

orig_color = the_button.cget("background")
the_button.configure(background="red")
...
the_button.configure(background=orig_color)

The default colour for buttons is SystemButtonFace. I am not sure how many versions of Windows this spans back to, but it is the default system colour for buttons.

You can find the default colours by using @Bryan Oakley's answer above, and then print() it to the console.

Tags:

Python

Tkinter