1

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()
4

3 回答 3

3

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)
于 2013-03-30T18:12:45.413 回答
0

Assuming the root window is name root, you would do:

root.configure(background=color)
于 2013-03-30T17:43:24.800 回答
0

Bryan Oakley code is correct

root.configure(background="color")

but, color must be enclosed with quotes single('') or double("")

于 2016-06-23T15:39:39.273 回答