- from tkinter import *
- import os
- path = os.getcwd()
- arr = []
- for files in next(os.walk('/home/vimart/Python/img/'))[2]:
- arr.append('/home/vimart/Python/img' + "/" + files)
- canvas_width = 300
- canvas_height =300
- master = Tk()
- canvas = Canvas(master,
- width=canvas_width,
- height=canvas_height)
- canvas.pack()
- img = PhotoImage(file="sport.gif")
- canvas.create_image(20,20, anchor=NW, image=img)
- def chang():
- for pictures in arr:
- canvas.delete("all")
- def change_img():
- canvas.img= PhotoImage(file = pictures)
- canvas.create_image(20,20, anchor=NW, image=canvas.img)
- master.after(3000, change_img)
- master.after(3000, chang)
- mainloop()