Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import PIL.Image, PIL.ImageTk, PIL.ImageDraw, PIL.ImageFont
- from itertools import count
- class Guage(Label):
- def load(self, im):
- if isinstance(im, str):
- im = PIL.Image.open(im)
- self.loc = 0
- self.frames = []
- try:
- for i in count(1):
- self.frames.append(PIL.ImageTk.PhotoImage(im.copy()))
- im.seek(i)
- except EOFError:
- pass
- try:
- self.delay = im.info['duration']
- except:
- self.delay = 100
- if len(self.frames) == 1:
- self.config(image=self.frames[0])
- def unload(self):
- self.config(image=None)
- self.frames = None
- def progress(self, p):
- if isinstance(p, int):
- if self.frames:
- print(p)
- print(len(self.frames))
- if p <= len(self.frames)-1:
- self.config(image=self.frames[p])
- else:
- self.config(image=self.frames[len(self.frames)-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement