Background color for Tk in Python

Solution 1:

root.configure(background='black')

or more generally

<widget>.configure(background='black')

Solution 2:

I know this is kinda an old question but:

root["bg"] = "black"

will also do what you want and it involves less typing.

Solution 3:

Its been updated so

root.configure(background="red")

is now:

root.configure(bg="red")

Solution 4:

widget['bg'] = '#000000'

or

widget['background'] = '#000000'

would also work as hex-valued colors are also accepted.

Solution 5:

config is another option:

widget1.config(bg='black')
widget2.config(bg='#000000')

or:

widget1.config(background='black')
widget2.config(background='#000000')