애플리케이션의 Tkinter 위젯은 투명 배경으로 제공될 수 있습니다. 모든 위젯의 배경 속성은 위젯 자체에 의해 제어됩니다.
그러나 특정 위젯에 투명한 배경을 제공하려면 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()
출력
위의 코드를 컴파일하면 투명한 배경에 Label 위젯이 있는 창이 표시됩니다.