Creating a transparent background in a Tkinter window

TkinterPythonGUI-Programming

Tkinter window provides many inbuilt functions and properties to help an application work seamlessly. They configure the GUI of the application as well.

If we want to create a transparent window in an application, then we should have to define the color in the attributes('-transparentcolor', 'color' ) method. By providing the color of the window and widget, it will make the window transparent.

Example

#Import the Tkinter Library
from tkinter import *

#Create an instance of Tkinter Frame
win = Tk()

#Set the geometry of window
win.geometry("700x350")

#Add a background color to the Main Window
win.config(bg = '#add123')

#Create a transparent window
win.wm_attributes('-transparentcolor','#add123')
win.mainloop()

Output

Running the above code will display a window with a transparent background.

raja
Published on 25-May-2021 09:33:06
Advertisements