How can I change color of tkinter window(background) in python 3, by using colorchooser?
for now I made this:
from tkinter import colorchooser
def color1():
color = colorchooser.askcolor()
How can I change color of tkinter window(background) in python 3, by using colorchooser?
for now I made this:
from tkinter import colorchooser
def color1():
color = colorchooser.askcolor()
For a window named root, to change the background color using colorchooser, you would do:
color = colorchooser.askcolor()
color_name = color[1] #to pick up the color name in HTML notation, i.e. the 2nd element of the tuple returned by the colorchooser
root.configure(background=color_name)
Assuming the root window is name root
, you would do:
root.configure(background=color)
Bryan Oakley code is correct
root.configure(background="color")
but, color
must be enclosed with quotes single(''
) or double(""
)