zephyr
zephyr

Reputation: 2332

How to get the ttk Button background color?

I want to programmatically find out what color is being used for the background color of a tkinter ttk.Button. To be clear, I'm not trying to set or change the background color (since that cannot be done), merely get the color so I can use that color elsewhere. The standard process of cget('background') will not work for a ttk button, so how else might I get the button background color?

Note, this answer needs to be system independent.

Upvotes: 0

Views: 2189

Answers (1)

zephyr
zephyr

Reputation: 2332

Found the answer myself eventually.

from tkinter import ttk
print(ttk.Style().lookup('TButton', 'background'))

Upvotes: 4

Related Questions