-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
75 lines (60 loc) · 2.5 KB
/
main.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import shutil
from tkinter import *
import tkinter as tk
from PIL import Image, ImageTk
import os
import time
from home import Home
class Screen:
def __init__(self):
self.root = tk.Tk()
self.root.attributes('-fullscreen', True)
# setting background image
self.image = Image.open("Photos/background.png")
self.backgroundImage = ImageTk.PhotoImage(self.image)
self.backgroundLabel = Label(self.root, image=self.backgroundImage)
self.main_frame = tk.Frame(self.root, borderwidth=0, background='#191142')
self.image_label = tk.Label(self.main_frame, image="", borderwidth=0, background='#191142')
self.logo = Image.open("Photos/logo.png")
self.logoImage = ImageTk.PhotoImage(self.logo)
self.logoLabel = Label(self.root, image=self.logoImage, background='#191142')
self.loading = Image.open("Photos/loading.png")
self.loadingImage = ImageTk.PhotoImage(self.loading)
self.loadingLabel = Label(self.root, image=self.loadingImage, background='#191142')
self.backgroundLabel.place(x=0, y=0)
self.main_frame.place(anchor='center', relx=0.5, rely=0.45)
self.logoLabel.place(anchor='center', relx=0.5, y=100)
self.loadingLabel.place(anchor='center', relx=0.5, rely=0.87)
self.image_label.pack()
os.mkdir("gif_frames")
self.start = time.time()
self.gif_frames = []
self.images = []
self.animation()
self.root.mainloop()
def animation(self):
gif = Image.open("Photos/splashScreen.gif")
self.no_of_frames = gif.n_frames
for i in range(self.no_of_frames):
gif.seek(i)
gif.save(os.path.join("gif_frames", f"gif{i}.png"))
self.gif_frames.append(os.path.join("gif_frames", f"gif{i}.png"))
for images in self.gif_frames:
im = Image.open(images)
im = im.resize((800, 650), Image.Resampling.LANCZOS)
im = ImageTk.PhotoImage(im)
self.images.append(im)
self.show_animation(0)
def show_animation(self, count):
image = self.images[count]
self.image_label.configure(image=image)
count += 1
if count == len(self.images) - 1:
count = 0
if (time.time() - self.start) <= 10:
self.x = self.root.after(13, self.show_animation, count)
elif (time.time() - self.start) > 10:
self.root.destroy()
shutil.rmtree('gif_frames')
Home()
Screen()