-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
104 lines (82 loc) · 2.96 KB
/
__init__.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import os
import sys
import numpy
SCRIPT_DIR = os.path.dirname(__file__)
sys.path.append(os.path.dirname(SCRIPT_DIR))
from customtkinter import *
from core.auth import *
from core.config import *
from core.database import *
from core.defaultentry import *
from core.imagetk import *
from core.messagebox import *
from core.models import *
from core.utils import *
from core.panel import *
def fade_in_out(current, next, *args, **kwargs):
next = next
def fade_away():
alpha = current.attributes("-alpha")
if alpha > 0:
current.attributes("-alpha", alpha-0.1)
current.after(30, fade_away)
else:
current.destroy()
nonlocal next
next = next(*args, **kwargs)
next.root.attributes("-alpha", 0.0)
fade_in()
def fade_in():
alpha = current.attributes("-alpha")
if alpha < 1:
current.attributes("-alpha", alpha+0.1)
current.after(30, fade_in)
current.after(1000, fade_away)
def loading_screen(cls: Login):
# cls.root.after(1000)
# cls.root.destroy()
# creating a new window while the old one is running
# causes the gif and other labels to not even work
# so destroying it and creating a new one is better
# using cls.root.after(1000, cls.root.destroy)
# still creates next window so by just waiting for 1 second
# then destroying manually works
win = CTk()
win.overrideredirect(True)
w ,h, length, posx, posy = calculate(900, 500)
win.geometry(f"{w}x{h}")
win.minsize(w, h)
center(win, w, h)
prog_bar = CTkProgressBar(win, width=length)
prog_bar.set(0)
loading_text=CTkLabel(win, text="Loading...", width=250, fg_color=None)
loading_perc=CTkLabel(win, text="0%", fg_color=None)
title=CTkLabel(win, text="Hospital Program",
text_font=("Shree Devanagari 714", 30),
corner_radius=8, width=330, height=48,
fg_color=None)
title.pack(pady=5)
gif=GIF("assets/basic/medi.gif", win, width=200, height=200)
gif.start()
gif.pack(pady=30)
prog_bar.place(x=posx, y=posy)
loading_text.place(x=posx-50, y=posy-50)
loading_perc.place(x=w-150, y=posy-50)
def run():
operations = iter((
"Connecting to a database...",
"Loading Theme...",
"Loading Fonts...",
"Starting Program...",
))
for start in numpy.arange(0, 1, .25):
win.after(50)
loading_text.set_text(text=next(operations))
for num in numpy.arange(start, start+.25, 0.00025):
prog_bar.set(num)
loading_perc.set_text(text=f"{round(num, 2)*100}%")
win.update()
win.after(500) # wait for .5 seconds
run() # load the things
fade_in_out(win, cls.main) # fade in and out
win.mainloop()