Search code examples
pythontkinterttk

(python, tkinter, ttk, style) How to change the whole color of ttk.Button?


I am trying to make a button change the color.

Here is my code :

 root = tk.Tk()
 style = ttk.Style()
 style.configure("test.TButton", background="white", foreground="white")
 test_btn = ttk.Button(root, style="test.TButton")
 test_btn.pack()
 root.mainloop()

I want to change the whole color of button. but its ridge(or margin or little of little of part of button) has been changed.

I tried same approach to change the color on "ttk.Label". it works perfect. Is there a way to change the whole color of "ttk.Button" ??

Specifially, I want to make a button with image and the other part of button transparent. So, I want to match the other part with same color of background.


Solution

  • Answer To Your Question is- There Is Now Way To Style A ttk button,

    But You You Can Infinitely Style A Normal tk.Button like this-

    from tkinter import *
    
    root = Tk()
    
    
    test_btn = Button(root, text="YOUR TEXT IS HERE!", background='crimson', foreground='white', width=30, 
    height=5, font=('Segoe UI', 40))
    test_btn.pack()
    
    
    root.mainloop()