-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.py
84 lines (78 loc) · 2.59 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
76
77
78
79
80
81
82
83
84
from app import App
import customtkinter as ctk
from widgets import AlertWindow
from settings import (
AppearanceSettings,
GeneralSettings
)
from services import (
DownloadManager,
LoadManager,
ThemeManager,
LoadingIndicateManager,
LanguageManager,
VideoCountTracker
)
from utils import FileUtility
# Initialize app.
app = App()
# configure settings
GeneralSettings.initialize()
AppearanceSettings.initialize()
LanguageManager.initialize()
# Check directory accessibility during startup.
# If accessible, nothing happens if not, show an error message.
scale = AppearanceSettings.settings["scale_r"]
DIRECTORIES = [GeneralSettings.backup_dir, GeneralSettings.settings["download_directory"]]
for directory in DIRECTORIES:
print("Checking Accesibility :", directory)
if not FileUtility.is_accessible(directory):
AlertWindow(
master=app,
alert_msg="run_as_admin_mode",
ok_button_display=True,
ok_button_callback=app.on_app_closing,
callback=app.on_app_closing,
width=int(450 * scale),
height=int(130 * scale)
)
# configure services
LoadManager.initialize(app.update_active_videos_count_status)
DownloadManager.initialize(app.update_active_videos_count_status)
VideoCountTracker.initialize(app.update_total_videos_count_status)
ThemeManager.initialize()
LoadingIndicateManager.initialize()
# set the theme mode, dark or light or system, by getting from data
ctk.set_appearance_mode(AppearanceSettings.themes[AppearanceSettings.settings["root"]["theme_mode"]])
# deactivate the automatic scale
ctk.deactivate_automatic_dpi_awareness()
# place the app at the last placed geometry
app.geometry(GeneralSettings.settings["window_geometry"])
# set minimum window size to 900x500
app.minsize(int(900 * scale), int(500 * scale))
# configure alpha
app.attributes("-alpha", AppearanceSettings.settings["opacity_r"])
# set the title icon
app.iconbitmap("assets\\main icon\\512x512.ico")
# set the app title
app.title("PyTube Downloader")
# Create the main widgets of the application
app.create_widgets()
# set widgets sizes
app.set_widgets_sizes()
# set texts depend on language
app.set_widgets_texts()
# place main widgets
app.place_widgets()
# configure colors for main widgets
app.set_widgets_colors()
# configure theme color
app.set_widgets_accent_color()
# configure fonts for main widgets
app.set_widgets_fonts()
# app event bind
app.bind_widgets_events()
# bind shortcut keys
app.bind_keyboard_shortcuts()
# just rut the app
app.run()