|
发表于 2018-9-16 16:18:50
|
显示全部楼层
本楼为最佳答案
本帖最后由 塔利班 于 2018-9-16 16:25 编辑
- from tkinter import *
- from PIL import Image,ImageTk
- root=Tk()
- IMG=[]
- for i in range(1,15):
- im=Image.open(r'G:\学习\图片\\'+str(i)+'.jpg')
- img=ImageTk.PhotoImage(im)
- IMG.append(img)
- counter=0
- label=Label(root,image=IMG[counter])
- label.grid(row=1)
- def chimg():
- global label
- global counter
- if counter<13:
- counter+=1
- else:
- counter=0
- label.destroy()
- label=Label(root,image=IMG[counter])
- label.grid(row=1)
- Button(root,text='换图',command=chimg).grid(row=0)
- mainloop()
复制代码
我的图片是1-14.jpg |
|