【发布时间】:2020-09-01 18:58:13
【问题描述】:
我刚开始学习使用 Python 构建的 Tkinter 模块。我正在尝试使用枕头构建一个简单的图像查看器 GUI。我在这里遇到属性错误。
AttributeError: type object 'Image' has no attribute 'open'
这是我的代码:
from PIL import ImageTk,Image
from tkinter import *
base = Tk()
base.title("Image Viewer")
base.iconbitmap("download.ico")
img1 = ImageTk.PhotoImage(Image.open("download.png"))
label1 = Label(image = img1)
label1.grid(row = 0, column = 0, columnspan = 3)
base.mainloop()
我似乎无法找到解决此问题的方法,而且 StackOverflow 上类似问题的解决方案都没有。
【问题讨论】:
标签: python tkinter python-imaging-library attributeerror