因此,我试图使用PIL打开图像,调整其大小,然后将其放在tkinter画布上。我已经尝试导入TkImage:
import TkImage
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'TkImage'
from PIL import TkImage
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TkImage'
from PIL.Image import TkImage
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TkImage'
from PIL.Image import Image
i = Image.TkImage()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'Image' has no attribute 'TkImage'
所有这些都会引发例外。有人可以帮忙吗?
PIL中没有命名为TkImage
的东西。但是,有一个名为ImageTk
的东西。
from PIL import ImageTk