Gifimiz;
class AnimGif(tk.Label):
def __init__(self, master, *args, **kwargs):
tk.Label.__init__(self, master, *args, **kwargs)
self.configure(borderwidth="0")
def load(self, im):
if isinstance(im, str):
im = Image.open(im)
self.loc = 0
self.frames = []
try:
for i in count(1):
self.frames.append(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])
else:
self.next_frame()
def unload(self):
self.config(image=None)
self.frames = None
def next_frame(self):
if self.frames:
self.loc += 1
self.loc %= len(self.frames)
self.config(image=self.frames[self.loc])
self.after(self.delay, self.next_frame)
class myApp:
def __init__(self, app=None):
app.title("Animation")
self.bg = AnimGif(app)
self.bg.load("d0b63dac61f49068926f890bb674743131eb1f98.gif")
self.bg.pack()
def start_gui():
global root
root = tk.Tk()
app = myApp(root)
root.mainloop()
if __name__ == '__main__':
from PIL import Image, ImageTk
from itertools import count
import tkinter as tk
start_gui()
Çıkışı ;