I want to have all my labels and buttons to have a white background.
I know I can use bg="white"
in each one but I was thinking if there was a way I could change the default colour to white or make it so that all widgets have a white background with a single line of code. similar to how you can change the font by doing:
from tkinter import *
window=Tk()
window.option_add("*font",("Arial",15))
window.mainloop()
Which will set all the font to Arial 15
CodePudding user response:
Unfortunately, as far as I'm aware there is no such natively supported function. However, you could make your own custom method to do just this. Here's an idea of what I'm talking about:
def whiteButton(window, text, fg):
return Button(window, text = text, bg='white', fg=fg)
I hope that was helpful:)
CodePudding user response:
thanks to @acw1668 's comment, can do
window.option_add("*Label*Background", "white")
and
window.option_add("*Button*Background", "white")
to solve it. Just thought id put it as an answer in case people don't see the comment and what not.