- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create transparent widgets using Tkinter?
A Tkinter widget in an application can be provided with Transparent background. The background property of any widget is controlled by the widget itself.
However, to provide a transparent background to a particular widget, we have to use wm_attributes('transparentcolor', 'colorname') method. It works in the widget only after adding the same transparent color as the background color of the widget.
#Import the required libraries from tkinter import * #Create an instance of Tkinter Frame win = Tk() #Set the geometry win.geometry("700x250") #Adding transparent background property win.wm_attributes('-transparentcolor', '#ab23ff') #Create a Label Label(win, text= "This is a New line Text", font= ('Helvetica 18'), bg= '#ab23ff').pack(ipadx= 50, ipady=50, padx= 20) win.mainloop()
When we compile the above code, it will display a window with a Label widget in transparent background.
- Configure tkinter/ttk widgets with transparent backgrounds
- How to delete Tkinter widgets from a window?
- How to show and hide widgets in Tkinter?
- How to capture events on Tkinter child widgets?
- How to make a Tkinter canvas rectangle transparent?
- Showing and Hiding widgets in Tkinter?
- How to create a transparent histogram using ggplot2 in R?
- How to create a transparent polygon using ggplot2 in R?
- How to create transparent bar plot using ggplot2 in R?
- How to set the border color of certain Tkinter widgets?
- How do you overlap widgets/frames in Python tkinter?
- How to create transparent boxplot in R?
- How to create a timer using tkinter?
- How to create an image with a transparent background text using CSS?
- How to position Tkinter widgets so that they are not stuck together?