How do I change the background of a Frame in Tkinter?
I have been creating an Email program using Tkinter, in Python 3.3. On various sites I have been seeing that the Frame widget can get a different background using Frame.config(background=»color») . However, when I use this in my Frames it gives the following error:
It does not work when doing the following:
I can’t figure it out. I would post my whole source code but I dont want it exposed on the internet, but the frame creation goes something like this:
I have tried multiple options trying to modify the background. The frame is like a wrap around an email preview for an inbox.
In case it’s needed, this the way I am importing my modules:
The following is the full traceback:
Gives the following error with the code from the answer:
Solved! Thanks. Its the inbox bar to the right, background needed to be white. 
How to change a Tkinter window background color
Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2023 with this popular free course.
Tkinter is one of the GUI modules available in Python. It comes with the Python standard library. It is used to create cross-platform desktop GUI applications. It is lightweight and easy to use compared to other GUI modules available in Python. In this answer, we'll learn to change the background color of the Tkinter window.
Syntax
We can specify the color with the color name or use the hex value.
Code example
Let's look at an example below:
Code explanation
In the above code snippet:
Line 5: We create an instance of the Tkinter class Tk() and assign it to the variable window .
Line 8: We set the size of the window as 300×300 px using the geometry method.
Line 11: We set the background color of the window as red by passing red as value to the bg attribute in the configure method.
Set Tkinter Background Color

Tkinter widget class method configure and attribute bg or background could be used to set the Tkinter widget/window background color.
Method configure(background= )
app.configure(bg=’red’) configures the background color of app to be red . You could also use background instead of bg .
Attribute bg or background
background or bg is one attribute in most of Tkinter widgets, and could be used to set the background color directly.
Tkinter Window Background Color
The default background color of a GUI with Tkinter is grey. You can change that to any color based on your application’s requirement.
In this tutorial, we will learn how to change the background color of Tkinter window.
There are two ways through which you can change the background color of window in Tkinter. They are:
- using configure(bg=») method of tkinter.Tk class. or
- directly set the property bg of tkinter.Tk.
In both of the above said cases, set bg property with a valid color value. You can either provide a valid color name or a 6-digit hex value with # preceding the value, as a string.
Examples
1. Change background color using configure method
In this example, we will change the Tkinter window’s background color to blue.
Python Program
Output

2. Change background color using bg property
In this example, we will change the Tkinter window’s background color to blue.
Python Program
Output

3. Using background for bg
You can use the property name bg as in the above two examples, or also use the full form background. In this example, we will use the full form background to set the background color of Tkinter window.
Python Program
Output
4. Using HEX code for background color
As already mentioned during the start, you can provide a HEX equivalent value for a color. In this example, we provide a HEX value to color and check the output.
Python Program
Output
Summary
In this tutorial of Python Examples, we learned how to change the background color of Tkinter GUI window, with the help of well detailed Python example programs.