-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathlow_level_alert_window.py
118 lines (104 loc) · 4.73 KB
/
low_level_alert_window.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import customtkinter as ctk
import time
from PIL import Image
from typing import Callable
from settings import AppearanceSettings
from services import LanguageManager
class LowLevelAlertWindow(ctk.CTk):
"""
Use to track any alert windows running or not
"""
def __init__(self,
alert_msg: str = "something_went_wrong",
ok_button_display: bool = None,
ok_button_callback: Callable = None,
cancel_button_display: bool = None,
cancel_button_callback: Callable = None,
callback: Callable = None,
more_details: str = None,
width: int = 400,
height: int = 200):
super().__init__(fg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],)
scale = AppearanceSettings.settings["scale_r"]
self.callback = callback
self.width = width
self.height = height
self.geometry(f"{self.width}x{self.height}")
self.attributes("-alpha", AppearanceSettings.settings["opacity_r"])
self.resizable(False, False)
self.iconbitmap("assets\\main icon\\512x512.ico")
self.title("PytubeDownloader")
# Info Image
self.info_image = ctk.CTkImage(Image.open("assets\\ui images\\info.png"), size=(70 * scale, 70 * scale))
self.info_image_label = ctk.CTkLabel(
master=self,
text="",
image=self.info_image,
width=70, height=70
)
self.info_image_label.pack(side="left", fill="y", padx=(30 * scale, 10 * scale))
# Error Message Label
self.error_msg_label = ctk.CTkLabel(
master=self,
text=LanguageManager.data[alert_msg],
text_color=AppearanceSettings.settings["alert_window"]["msg_color"]["normal"],
font=("Arial", 13 * scale, "bold")
)
if more_details is None:
self.error_msg_label.pack(pady=(20 * scale, 15 * scale), padx=(0, 30 * scale))
else:
self.error_msg_label.pack(pady=(10 * scale, 0 * scale), padx=(0, 30 * scale))
# More Details (if provided)
if more_details is not None:
self.more_details_label = ctk.CTkLabel(
master=self,
text=more_details,
text_color=AppearanceSettings.settings["alert_window"]["details"]["normal"],
font=("Arial", 12 * scale, "bold")
)
self.more_details_label.pack(pady=(8 * scale, 15 * scale), padx=(0, 30 * scale))
# Cancel Button (if required)
if cancel_button_display is True:
self.cancel_button = ctk.CTkButton(
border_width=2,
border_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
master=self,
hover_color=AppearanceSettings.settings["root"]["accent_color"]["hover"],
command=self.on_click_cancel_button,
text=LanguageManager.data["cancel"],
fg_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
width=100 * scale,
height=28 * scale,
font=("Arial", 12 * scale, "bold")
)
self.cancel_button.pack(side="right", padx=(20 * scale, 40 * scale))
# OK Button (if required)
if ok_button_display is True:
self.ok_button = ctk.CTkButton(
border_width=2,
border_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
master=self,
hover_color=AppearanceSettings.settings["root"]["accent_color"]["hover"],
command=self.on_click_ok_button,
text=LanguageManager.data["ok"],
fg_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
width=100 * scale,
height=28 * scale,
font=("Arial", 12 * scale, "bold")
)
self.ok_button.pack(side="right", padx=(0, 20 * scale))
self.ok_button_callback = ok_button_callback
self.cancel_button_callback = cancel_button_callback
self.protocol("WM_DELETE_WINDOW", self.on_closing)
def on_closing(self):
self.destroy()
if self.callback is not None:
self.callback()
def on_click_ok_button(self):
if self.ok_button_callback is not None:
self.ok_button_callback()
self.on_closing()
def on_click_cancel_button(self):
if self.cancel_button_callback is not None:
self.cancel_button_callback()
self.on_closing()