I'm new to tkinter and I can't set the background color of a button
My code:
from tkinter import *
from tkinter import ttk
root = Tk()
frame = Frame(root).grid(row = 0, column = 0)
button = ttk.Button(frame, text = "CLICK ME", bg = '#05752a').grid(row = 0, column = 0)
root.mainloop()
ERROR:
_tkinter.TclError: unknown option "-bg"
CodePudding user response:
Unfortunately, there isn't an easy way to change the background of a button from the ttk library.
But you can easily get what you want with a normal tkinter. Button if you set the right options. Below is an example script:
from tkinter import *
from tkinter import ttk
root = Tk()
frame = Frame(root).grid(row = 0, column = 0)
button = Button(frame, text = "CLICK ME", bg = '#05752a').grid(row = 0, column = 0)
root.mainloop()
This is the Link to another post