Is there any way to change the background color of ttk buttons in python? I tried using style method but it just changes the border colour Is there any way to change the background color of ttk buttons in python? I tried using style method but it just changes the border colour tkinter tkinter

Is there any way to change the background color of ttk buttons in python? I tried using style method but it just changes the border colour


I also suffered from the same problem.You can change the intended background color by using TLabel instead of TButton.However, there is no padding space around the button level text. You need to specify padding with the configure method.If you specify TLabel, Style as a button seems to be lost, and you also need to specify relief.

from tkinter import *from tkinter.ttk import *from tkinter import ttkroot = Tk()stl = ttk.Style()root.geometry('800x600')stl = ttk.Style()stl.configure('C.TLabel',padding=[30,10,50,60])stl.map('C.TLabel',    foreground = [('pressed','red'),('active','blue')],    background = [('pressed','!disabled','black'),('active','white')],    relief=[('pressed', 'sunken'),            ('!pressed', 'raised')])ttk.Button(root, text='This is a button', style='C.TLabel').pack()root.mainloop()