TheQuiteStupidMan
TheQuiteStupidMan

Reputation: 45

Changing color of background of tkinter window by using colorchooser in python 3 and tkinter

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

Upvotes: 1

Views: 7527

Answers (3)

Umesh
Umesh

Reputation: 1

Bryan Oakley code is correct

root.configure(background="color")

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

Upvotes: 0

sissi_luaty
sissi_luaty

Reputation: 2889

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)

Upvotes: 3

Bryan Oakley
Bryan Oakley

Reputation: 386362

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

root.configure(background=color)

Upvotes: 0

Related Questions