Styling Tkinter widgets
Tkinter has essentially two styling systems: the old Tkinter widgets system, and the newer Ttk system. Although we are using Ttk widgets wherever possible, there are still situations where regular Tkinter widgets are required, so it's good to know both systems. Let's take a look first at the older Tkinter system and apply some styling to the Tkinter widgets in our application.
Widget color properties
As you saw in Chapter 1, Introduction to Tkinter, basic Tkinter widgets allow you to change two color values: the foreground color, meaning mainly the color of text and borders, and the background color, meaning the rest of the widget. These can be set using the foreground
and background
arguments, or their aliases, fg
and bg
.
For example, we can set the colors of a label like so:
# tkinter_color_demo.py
import tkinter as tk
l = tk.Label(text='Hot Dog Stand!', fg='yellow', bg='red')
The values for the...