2021
04-27
04-27
Python使用tkinter加载png、jpg等图片
首先PhotoImage注意这里只支持gif格式的图片photo=PhotoImage(file="D:/python/images/02.gif")发现tkinter是只支持gif的格式,如果要加载png或者jpg的话就要使用PIL模块fromtkinterimport*fromPILimportImage,ImageTkroot=Tk()root.title('测试组python毕业题')img=Image.open('ques.png')#打开图片photo=ImageTk.PhotoImage(img)#用PIL模块的PhotoImage打开imglabel=Label(root,image=photo)imglabel.gr...
继续阅读 >