I have been trying to figure out why this has been happening when I try to access my hex colour as the background color in window, searched for the solution everywhere but didn't got the exact one.
It is throwing -> tkinter.TclError: unknown color name 'f7f5dd'
.
Please guide me the way :
from tkinter import *
YELLOW = "f7f5dd"
window = Tk()
window.minsize(width=400, height=300)
window.title("Pomodoro App")
window.config(padx=100, pady=50,bg=YELLOW)
window.mainloop()
CodePudding user response:
Just add the hash symbol/number-sign to the front of the color string.
from tkinter import *
YELLOW = "#f7f5dd"
window = Tk()
window.minsize(width=400, height=300)
window.title("Pomodoro App")
window.config(padx=100, pady=50,bg=YELLOW)
window.mainloop()
CodePudding user response:
Instead of window.config
. You can use this. Add symbol #
in front of color string.
from tkinter import *
YELLOW = "#f7f5dd"
window = Tk()
window.minsize(width=400, height=300)
window.title("Pomodoro App")
window['background']=YELLOW
window.mainloop()