我试图呈现一个标签内的图像,虽然当我打印标签时,里面没有图像。这是我的密码。在
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()
图像与代码位于同一个文件中。我是否正确加载图像?在
编辑: 此代码生成完全相同的输出。在
^{pr2}$编辑:
它只需要courtImg = PhotoImage(file='basketballCourtTemplate.gif')
目前没有回答
相关问题 更多 >
编程相关推荐