Friday, December 19, 2025
HomeLanguagesTransparent window in Tkinter

Transparent window in Tkinter

Prerequisite: Python GUI – tkinter

Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python.

To create a transparent window, we will use the attributes() method.

Syntax:

root.attributes('-alpha',transparency value)

To create a transparent background, we need to use the -alpha argument in the attributes() method. The alpha is Used for transparency.

If the transparency value is 0.0 it means fully transparent, 1.0 means fully opaque The range is [0.0,1.0].  This isn’t supported on all systems, Tkinter always uses 1.0. Note that in this release, this attribute must be given as -alpha.

Below is a program that creates a normal Tkinter window.

Python3




# Import module
from tkinter import *
 
# Create object
root = Tk()
 
# Adjust size
root.geometry("400x400")
 
# Execute tkinter
root.mainloop()


Output:

Non-transparent Window

Now, the below program creates a transparent window using tkinter module.

Python3




# Import module
from tkinter import *
 
# Create object
root = Tk()
 
# Adjust size
root.geometry("400x400")
 
# Create transparent window
root.attributes('-alpha',0.5)
 
# Execute tkinter
root.mainloop()


Output:

 

Transparent Window

 

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32455 POSTS0 COMMENTS
Milvus
108 POSTS0 COMMENTS
Nango Kala
6823 POSTS0 COMMENTS
Nicole Veronica
11958 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12038 POSTS0 COMMENTS
Shaida Kate Naidoo
6958 POSTS0 COMMENTS
Ted Musemwa
7203 POSTS0 COMMENTS
Thapelo Manthata
6911 POSTS0 COMMENTS
Umr Jansen
6890 POSTS0 COMMENTS