Create a Python GUI window with custom background color
Python tkinter Basic: Exercise-11 with Solution
Write a Python GUI program that creates a window with a specific background color using Tkinter.
Sample Solution:
Python Code:
import tkinter as tk
# Create the main window
parent = tk.Tk()
parent.title("Window with Background Color")
# Set the background color of the window
parent.configure(bg="lightpink") # Replace " lightpink" with your desired color
# Start the Tkinter event loop
parent.mainloop()
In the exercise above, we set the background color of the window by using the parent.configure(bg=" lightpink") line. Replace " lightpink" with the specific background color you want to use (you can use color names or hexadecimal color codes).
Sample Output:
Flowchart:

Python Code Editor:
Previous: Customize labels and buttons in Python Tkinter.
Next: Add an image to a Tkinter window in Python.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
Python: Tips of the Day
Summing a sequence of numbers (calculating the sum of zero to ten with skips):
>>> l = range(0,10,2) >>> sum(l) 20
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook