-
Notifications
You must be signed in to change notification settings - Fork 0
/
loading.py
75 lines (58 loc) · 1.48 KB
/
loading.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
import tkinter as tk
from tkinter import ttk
import subprocess
import pygame
window = tk.Tk()
window.title("ROCK PAPER SCISSORS")
pygame.mixer.init()
pygame.mixer.music.load('openingmusic.mp3')
pygame.mixer.music.play()
image = tk.PhotoImage(file="opening.png")
width = image.width() // 2
height = image.height() // 2
image = image.subsample(2, 2)
bg_label = tk.Label(window, image=image)
bg_label.place(x=0, y=0)
screen_width = window.winfo_screenwidth()
screen_height = window.winfo_screenheight()
x = (screen_width - width) // 2
y = (screen_height - height) // 2
window.geometry(f"{width}x{height}+{x}+{y}")
progress_label = tk.Label(
window,
text="Loading...",
font=("Trebuchet Ms", 13, "bold"),
fg="#FFFFFF",
bg="#42f545",
)
progress_label.place(x=450, y=420)
progress = ttk.Progressbar(
window,
orient=tk.HORIZONTAL,
length=400,
mode="determinate",
style="red.Horizontal.TProgressbar",
)
progress.place(x=330, y=450)
def top():
window.withdraw()
pygame.mixer.music.stop()
subprocess.run(["python", "main_program.py"])
window.destroy()
i = 0
def load():
global i
if i <= 10:
txt = 'Loading.....' + str(10 * i) + '%'
progress_label.config(text=txt)
progress_label.after(600, load)
progress['value'] = 10 * i
i += 1
else:
top()
def on_closing():
window.destroy()
load()
window.resizable(False, False)
window.protocol("WM_DELETE_WINDOW",on_closing)
window.mainloop()