3
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://i.stack.imgur.com/JgOg0.jpg

stovfl
  • 14,998
  • 7
  • 24
  • 51
Chris
  • 351
  • 2
  • 4
  • 13
  • 1
    Huh? Don't understand what you're asking. The image I put below is how it looks, the white box shouldnt be there. – Chris Feb 15 '18 at 20:07
  • 1
    Please provide a [mcve] to reproduce the issue, and optionally update the image with _that_ code's _entire_ GUI. – Nae Feb 15 '18 at 20:10
  • 2
    There we go. Updated. – Chris Feb 15 '18 at 20:17
  • 1
    Thanks a lot. I think this is a much better question now. I edited your earlier one to show image embedded, you can do this by adding the image link as an image instead of a regular link. Note that if it lacks `mainloop` then the code above depends on something else to produce the GUI. – Nae Feb 15 '18 at 20:18
  • 1
    As in, the actual file? – Chris Feb 15 '18 at 20:19

1 Answers1

5

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']
Nae
  • 14,209
  • 7
  • 52
  • 79
  • 1
    What if I'm using an image for the background of the master – Chris Feb 15 '18 at 20:28
  • 1
    @Chris You may want to see [this](https://stackoverflow.com/q/17039481/7032856) and/or [this](https://stackoverflow.com/questions/10461045/python-tkinter-label-background-transparent). But it's not as easy as this one. – Nae Feb 15 '18 at 20:41