Before I am asked to look over other topics, I just want to say that I have and all of the solutions either involve calling a tk.Toplevel()
instead of tk.TK()
I actually can't reproduce the error, your code just doesn't show any image for me, but I do see two problems with the code you have.
The PhotoImage
class __init__
method is defined as
class PhotoImage(Image):
"""Widget which can display colored images in GIF, PPM/PGM format."""
def __init__(self, name=None, cnf={}, master=None, **kw):
"""Create an image with NAME.
Valid resource names: data, format, file, gamma, height, palette,
width."""
Image.__init__(self, 'photo', name, cnf, master, **kw)
This means that the first argument is name
. So when you call Logo = tk.PhotoImage("brand_logo.png")
, you create an image with the name brand_logo.png
, but without actually specifying which image file should be used. To specify the image file use the file
keyword argument:
Logo = tk.PhotoImage(file="brand_logo.png")
With that out of the way, Logo
is still a local variable to the __init__
function, so after that returns, Logo
will be garbage collected. To prevent this, make it an instance variable by renaming it to self.Logo
everywhere.