0
라벨을 인쇄 할 때 라벨 안에 이미지가 없는데도 이미지를 라벨 안에 표시하려고합니다. 여기 내 코드가있다.Tkinter 레이블에있는 이미지?
from tkinter import *
newGameWindow = Toplevel()
newGameWindow.title("New Game")
newGameWindow.config(bg = "grey")
newGameWindow.geometry('600x600')
courtImg = PhotoImage('basketballCourtTemplate.png')
photo = Label(newGameWindow, image= courtImg, height = 200, width =200)
photo.pack()
newGameWindow.mainloop()
이미지는 코드와 동일한 파일에 있습니다. 이미지를 올바르게로드합니까?
편집 : 이 코드는 정확히 동일한 출력을 생성합니다.
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()
편집
: 가 필요한 모든 리눅스에서courtImg = PhotoImage(file='basketballCourtTemplate.gif')
[왜 내 Tkinter 이미지가 나타나지 않습니까?] (http://effbot.org/pyfaq/why-do-my-tkinter-images-not-appear.htm) – Lafexlos