Tkinter transparency on label

20,006

It's not that the Label can't show a transparent image, it's rather label has its own background color which is not transparent or the same as its parent. One workaround would simply be using its parent's bg as its own bg:

topFrame['bg'] = topFrame.master['bg']
Share:
20,006
Chris
Author by

Chris

Updated on February 04, 2020

Comments

  • Chris
    Chris about 4 years
    from tkinter import *
    
    master = Tk()
    master.resizable(False, False)
    master.geometry('430x480+50+50')
    master.title("Ping Check")
    master.config(bg="#222")
    
    layer = PhotoImage(file ="logo.gif")
    topFrame = Label(text="Ping Checker", image=layer, fg="#fff", font="Bahnschrift 14")
    topFrame.place(x=11,y=10)
    

    I'm using the following code, which displays the image, however, the label seems to have a background, which I do not want.

    Click for reference and the file https://imgur.com/a/JR4Hc

  • Chris
    Chris about 6 years
    What if I'm using an image for the background of the master
  • Nae
    Nae about 6 years
    @Chris You may want to see this and/or this. But it's not as easy as this one.