Tkinter has many feature attributes and properties to frame the structure of an application and configure the widget. In this article, we will see how to set Tkinter widgets with a transparent background. The wm_attributes('-transparentcolor', 'color') method is used for providing the transparent background to the widget.
Example
In this example, we will create a Label widget with transparent background.
#Import the required libraries from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry win.geometry("700x350") #Adding transparent background property win.wm_attributes('-transparentcolor', '#ab23ff') #Create a Label Label(win, text= "Hello World!", font= ('Helvetica 18'), bg= '#ab23ff').pack(ipadx= 50, ipady=50, padx= 20) win.mainloop()
Output
Running the above code will display a window that contains a Label with transparent background.