2012-06-07 82 views

回答

4

使用Tkinter PhotoImage類創建圖像對象,然後將該對象分配給Label小部件的image屬性。

欲瞭解更多信息,請參閱http://effbot.org/tkinterbook/photoimage.htm

+0

能否請你告訴我一個例子?我只需要一個帶有基本圖像的窗口和一個標籤。該圖像位於相同的目錄中,並命名爲image.gif。感謝 – user1402362

+0

Nvm,讓它工作。謝謝! – user1402362

0

這是非常簡單的:

photo = PhotoImage(file="C:\pictures\pic1.gif") 
label = Label(image=photo) 
label.pack() 
0

試試這個(對於Python 3)

from tkinter import PhotoImage 




photo = PhotoImage(file="/home/pi/pile.gif") 
lb=tkinter.Label(root,image = photo) 
lb.grid(row=4, column=1)