Im trying to present an image inside a label, although when I print the label there is no image inside it. Here is my code.
from tkinter import *
newGameWindow = Toplevel()
newGameWindow.title("New Game")
newGameWindow.config(bg = "grey")
newGameWindow.geometry('600x600')
#courtImg = PhotoImage('basketballCourtTemplate.png')
courtImg = PhotoImage(file ='basketballCourtTemplate.png')
photo = Label(newGameWindow, image= courtImg, height = 200, width =200)
photo.pack()
newGameWindow.mainloop()
the image is located in the same file as the code. Am I loading in the image correctly?
EDIT: this code produces exactly the same output.
from tkinter import *
newGameWindow = Toplevel()
newGameWindow.title("New Game")
newGameWindow.config(bg = "grey")
newGameWindow.geometry('600x600')
courtImg = PhotoImage('basketballCourtTemplate.gif')
photo = Label(newGameWindow, image= courtImg, height = 200, width =200)
photo.image = courtImg
photo.pack()
newGameWindow.mainloop()
EDIT:
All it needed was courtImg = PhotoImage(file='basketballCourtTemplate.gif')