-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.py
43 lines (33 loc) · 1.37 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import tkinter as tk
from PIL import Image, ImageTk
import imageio
class FullScreenApp:
def __init__(self, master, gif_path):
self.master = master
self.master.title("Fullscreen GIF App")
self.master.geometry("{0}x{1}+0+0".format(self.master.winfo_screenwidth(), self.master.winfo_screenheight()))
self.master.configure(bg="black")
self.gif_path = gif_path
self.gif_label = None
self.gif_frames = self.load_gif()
self.setup_gui()
def load_gif(self):
gif = imageio.mimread(self.gif_path)
frames = [Image.fromarray(img) for img in gif]
return frames
def setup_gui(self):
self.current_frame = 0
self.total_frames = len(self.gif_frames)
# Set highlightthickness and bd to 0 to remove the border
self.gif_label = tk.Label(self.master, bg="black", highlightthickness=0, bd=0)
self.gif_label.pack(expand=True)
self.update_gif()
self.master.after(100, self.animate_gif)
def update_gif(self):
frame_image = ImageTk.PhotoImage(self.gif_frames[self.current_frame])
self.gif_label.config(image=frame_image)
self.gif_label.image = frame_image
def animate_gif(self):
self.current_frame = (self.current_frame + 1) % self.total_frames
self.update_gif()
self.master.after(100, self.animate_gif)