Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_mimicgifs.py
- # mimic an animated GIF displaying a series of images
- import time
- from Tkinter import *
- import tkFileDialog
- import sys
- import os
- root = Tk()
- class Cv(): 0
- cv = Cv
- cv.path = ''
- oFiletype =("gif files","*.gif"),("jpg files","*.jpg"),("png files","*.png"),("all files","*.*")
- def askfolder():
- cv.path = tkFileDialog.askopenfilename(title = "Select file",filetypes=oFiletype)
- cv.path = os.path.dirname(cv.path)+'/'
- canvas = Canvas(width=99, height=99)
- canvas.pack()
- while 1:
- askfolder()
- cv.ani = [cv.path+z for z in os.listdir(cv.path) if z.endswith(('.gif','.jpg','.png'))]
- # extract width and height info
- photo = PhotoImage(file=cv.ani[0])
- wt = photo.width()
- ht = photo.height()
- canvas.config(height=ht, width=wt)
- try:
- # loop through the series of images
- for k in range(0, 200):
- photo = PhotoImage(file=cv.ani[k%len(cv.ani)])
- canvas.create_image(wt/2.0, ht/2.0, image=photo)
- canvas.update()
- time.sleep(0.05)
- except:
- break
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement