How do I change the background colour in tkinter?
For the window and for classic widgets, it is one option. The catch is that half the widgets in a modern tkinter app quietly ignore it.
import tkinter as tk
root = tk.Tk()
root.configure(bg="#e8f1f5")
tk.Label(root, text="Hello", bg="#e8f1f5", fg="#0b3954").pack(pady=20)
root.mainloop() Why bg does nothing on some widgets
tkinter has two families. The classic ones — tk.Label, tk.Button, tk.Frame, tk.Entry — take bg and fg directly. The themed ones from ttk — Combobox, Notebook, Treeview, Progressbar, and ttk.Button if you imported that — draw themselves from a style, and pass no colour options at all. Setting bg on one is not an error; it simply does nothing, which is why this is so confusing the first time.
To colour a ttk widget, define a named style and hand it to the widget:
from tkinter import ttk
style = ttk.Style()
style.configure("Accent.TButton", background="#087e8b", foreground="white")
ttk.Button(root, text="Save", style="Accent.TButton").pack()Colouring everything at once
option_add sets defaults for every classic widget created afterwards, which saves repeating bg= on all of them. It has no effect on ttk widgets — those follow the theme.
root.option_add("*Background", "#e8f1f5")
root.option_add("*Foreground", "#0b3954")What counts as a colour
Hex strings like "#e8f1f5" work everywhere, as do the X11 names — "white", "steelblue", "gray80". On macOS some system colours are available too, but they are not portable, so hex is the safe choice for anything you intend to hand to someone else.
When the theme fights you
On macOS in particular, ttk.Button backgrounds are drawn by the OS and ignore your style entirely. If you need buttons that genuinely look the same on every platform, either use classic tk.Button, or use a toolkit built for it — CustomTkinter and ttkbootstrap both draw their own widgets rather than deferring to the platform.
Doing it without the lookup
Pick a style and the whole project follows it — window, widgets and fonts — on the canvas and in the export. Because the designer knows which widgets are themed, per-widget colours are emitted as named ttk styles where a plain bg= would have done nothing, so what you see is what runs.
Lay the window out visually and read the generated Python as you go.
Open the tkinter designer →