Background color for Tk in Python

跟風遠走 提交于 2019-12-02 20:03:04
root.configure(background='black')

or more generally

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

I know this is kinda an old question but:

root["bg"] = "black"

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

Oskar Zyg on YT

Its been updated so

root.configure(background="red")

is now:

root.configure(bg="red")
widget['bg'] = '#000000'

or

widget['background'] = '#000000'

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

config is another option:

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

or:

widget1.config(background='black')
widget2.config(background='#000000')
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!