- 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
Configure tkinter/ttk widgets with transparent backgrounds
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.
- Related Articles
- How to create transparent widgets using Tkinter?
- Difference between .pack and .configure for widgets in Tkinter
- How to Use Images as Backgrounds in Tkinter?
- Showing and Hiding widgets in Tkinter?
- Adding Multiple Backgrounds with CSS3
- 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 remove Ttk Notebook Tab Dashed Line? (tkinter)
- How do you overlap widgets/frames in Python tkinter?
- Set a default value for a ttk Combobox in Tkinter?
- Why do we use import * and then ttk in TKinter?
- How to change the color of ttk button in Tkinter?
- Changing the Default Font for all the widgets in Tkinter
- How to set the border color of certain Tkinter widgets?

Advertisements