Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python Tkinter Logo Image not appearing on GUI

I am trying to put a logo in the upper left-hand corner of my window, but I am getting a completely blank window even though my logo is not the same color as the background. It is giving me no errors, which is making it difficult to troubleshoot.

Code:

from tkinter import *
from PIL import ImageTk, Image

def createTopPage():
    img = PhotoImage(file="CMACLOGO.png")
    label = Label(app, image=img)
    label.pack()


app = Tk()
screenHeight = app.winfo_screenheight()
screenWidth = app.winfo_screenwidth()
app.geometry("{0}x{1}".format(screenWidth,screenHeight))
createTopPage()
app.mainloop()

Thank you for any help/insight!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

from tkinter import *
from PIL import ImageTk, Image

def createTopPage():
    image = Image.open("CMACLOGO.png")
    img = ImageTk.PhotoImage(image)
    label = Label(app, image=img)
    label.image = img
    label.pack()

app = Tk()
screenHeight = app.winfo_screenheight()
screenWidth = app.winfo_screenwidth()
app.geometry("{0}x{1}".format(screenWidth, screenHeight))
createTopPage()
app.mainloop()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading