PngImageFile不可调用

时间:2018-03-30 13:25:46

标签: python tkinter

编程新手,我不断在tkinter中收到此错误,并会感谢一些反馈。

from tkinter import*
from PIL import Image,ImageTk
root=Tk()

w1=Label(root,text="1")
w2=Label(root,text="2")
w3=Label(root,text="3")

e1=Entry()
e2=Entry()
e3=Entry()
e1.grid(row=0,column=1)
e2.grid(row=1,column=1)
e3.grid(row=2,column=1)

w1.grid(row=0)
w2.grid(row=1)
w3.grid(row=2)

image = Image.open("beer.png")
photo = ImageTk.PhotoImage(image)

label = Label(image=photo)
label.image = photo # keep a reference!
label.grid()

错误:

Traceback (most recent call last)
<ipython-input-38-f5a359cde8c0> in <module>()
     20 
     21 image = Image.open("beer.png")
---> 22 photo = ImageTk.PhotoImage(image)
     23 
     24 label = Label(image=photo)

TypeError: 'PngImageFile' object is not callable

0 个答案:

没有答案