解决python tkinter 展示jpg、png格式图片的问题
作者:互联网
报错:
from tkinter import *
img = PhotoImage(file = r'D:\test\hero\暗黑元首\暗黑元首.jpg')
lable_show = Label(frame_show,imag = img)
解决:首先安装PIL库,使用pip命令
pip install pillow
然后使用PIL库获得ImageTk.PhotoImage对象代替tk.PhotoImage对象即可
from PIL import Image,ImageTk
img = ImageTk.PhotoImage(Image.open(r'D:\test\hero\暗黑元首\暗黑元首.jpg'))
lable_show = Label(frame_show,imag = img)
标签:PhotoImage,tkinter,img,show,python,jpg,暗黑,PIL 来源: https://blog.csdn.net/zy1007531447/article/details/111192269