Python Forum
[Tkinter] Change background color - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] Change background color (/thread-1166.html)



Change background color - sparkz_alot - Dec-09-2016

I'm trying my first GUI application and was wondering if there is a way to change the background attribute of a Label (or Button?) if a condition changes while the applications is running. I see where you can change the text, but I can't find anything regarding other attributes such as background.

Thanks


RE: Change background color - Barrowman - Dec-09-2016

yes you can change it if you are using tkinter ( python3 ) or Tkinter ( python2 )
button.config(bg="#ffdddd")
would change the background of a button.
the #ffdddd is the levels of red, green and blue to make your background colour. they are each 2 digit hex numbers from 0 to 255 decimal.


RE: Change background color - Larz60+ - Dec-09-2016

You might be interested in this tutorial (One of the best in my humble opinion) http://www.python-course.eu/python_tkinter.php


RE: Change background color - sparkz_alot - Dec-10-2016

Sorry for the delay, busy day yesterday.  Thanks for the tips, I will read and experiment more.