- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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.
Example
#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()
Output
When we compile the above code, it will display a window with a Label widget in transparent background.
- Related Articles
- Configure tkinter/ttk widgets with transparent backgrounds
- How to show and hide widgets in Tkinter?
- How to capture events on Tkinter child widgets?
- How to delete Tkinter widgets from a window?
- How to set the border color of certain Tkinter widgets?
- Showing and Hiding widgets in Tkinter?
- How to make a Tkinter canvas rectangle transparent?
- 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 do you overlap widgets/frames in Python tkinter?
- How to create a timer using tkinter?
- How to position Tkinter widgets so that they are not stuck together?
- How to create a Splash Screen using Tkinter?
- How to create a simple screen using Tkinter?

Advertisements