किसी एप्लिकेशन में एक टिंकर विजेट पारदर्शी पृष्ठभूमि के साथ प्रदान किया जा सकता है। किसी भी विजेट की पृष्ठभूमि संपत्ति विजेट द्वारा ही नियंत्रित होती है।
हालांकि, किसी विशेष विजेट को पारदर्शी पृष्ठभूमि प्रदान करने के लिए, हमें wm_attributes('transparentcolor', 'colorname') का उपयोग करना होगा। तरीका। यह विजेट में पृष्ठभूमि रंग के समान पारदर्शी रंग जोड़ने के बाद ही विजेट में काम करता है।
उदाहरण
#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() आउटपुट
जब हम उपरोक्त कोड को संकलित करते हैं, तो यह पारदर्शी पृष्ठभूमि में एक लेबल विजेट के साथ एक विंडो प्रदर्शित करेगा।
