import tkinter as tk,os
class Application(tk.Frame):
def __init__(self,master=None):
self.files=os.listdir(r'D:\Picture')
self.index=0
self.img=tk.PhotoImage(file=r'D:\Picture'+'\\'+self.files[self.index])
tk.Frame.__init__(self,master)
self.pack()
self.createWidgets()
def createWidgets(self):
self.lblImage=tk.Label(self,width=300,height=300)
self.lblImage['image']=self.img
self.lblImage.pack()
self.f=tk.Frame()
self.f.pack()
self.btnPrev=tk.Button(self.f,text='上一张',command=self.prev)
self.btnPrev.pack(side=tk.LEFT)
self.btnNext=tk.Button(self.f,text='下一张',command=self.next)
self.btnNext.pack(side=tk.LEFT)
def prev(self):
self.showfile(-1)
def next(self):
self.showfile(1)
2017.08.16 利用python构建简易图片浏览器
最新推荐文章于 2024-07-10 22:01:27 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)