Search code examples
pythoncolorsbackgroundwindowtkinter

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

Solution

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