-
Notifications
You must be signed in to change notification settings - Fork 14
/
app.py
1579 lines (1341 loc) · 68.1 KB
/
app.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import customtkinter as ctk
import tkinter as tk
import threading
import time
import webbrowser
from typing import Literal
import pyautogui
from widgets import (
AddedVideo,
DownloadingVideo,
DownloadedVideo,
AddedPlayList,
DownloadingPlayList,
DownloadedPlayList,
SettingPanel,
TrayMenu,
AlertWindow
)
from widgets.core_widgets.context_menu import ContextMenu
from services import (
ThemeManager,
DownloadManager,
LoadManager,
LanguageManager
)
from settings import (
AppearanceSettings,
GeneralSettings,
)
from utils import (
FileUtility,
DataRetriveUtility
)
class App(ctk.CTk):
"""
Initialize the application.
This method sets up the initial state of the application by initializing attributes and widgets.
Attributes:
root_width (int): The initial width of the application window.
root_height (int): The initial height of the application window.
is_geometry_changes_tracker_running (bool): A flag indicating whether the geometry changes tracker is
running.
selected_download_mode (str): The selected download mode, either "video" or "playlist".
is_content_downloading (bool): A flag indicating whether content is currently being downloaded.
is_content_downloaded (bool): A flag indicating whether content has been downloaded.
is_content_added (bool): A flag indicating whether content has been added.
added_video_count (int): The number of added videos.
downloading_video_count (int): The number of videos currently being downloaded.
downloaded_video_count (int): The number of videos that have been downloaded.
# Add more attributes as needed...
Widgets:
url_entry (tk.Entry): Entry widget for entering URLs.
add_url_btn (tk.Button): Button widget for adding URLs.
# Add more widget descriptions as needed...
"""
def __init__(self) -> None:
super().__init__()
# window width height save on these vars.
# I will track window width, if it changed,app will call geometry tracker.
self.root_width = self.winfo_width()
self.root_height = self.winfo_height()
# this var used to track status of geometry tracker. it's running or not
# if it's running already running it's not be start again
self.is_geometry_changes_tracker_running = False
# Track app accessibility to all directories required
self.is_accessible_to_required_dirs = True
self.is_app_running = True
# download method
self.selected_download_mode = "video"
# check if any video added or downloading or downloaded
self.is_content_downloading = False
self.is_content_downloaded = False
self.is_content_added = False
self.added_video_count = 0
self.downloading_video_count = 0
self.downloaded_video_count = 0
# widgets
self.url_entry = None
self.add_url_btn = None
self.video_radio_btn = None
self.playlist_radio_btn = None
self.navigate_added_btn = None
self.navigate_downloading_btn = None
self.navigate_downloaded_btn = None
self.added_content_scroll_frame = None
self.downloading_content_scroll_frame = None
self.downloaded_content_scroll_frame = None
self.added_frame_info_label = None
self.downloading_frame_info_label = None
self.downloaded_frame_info_label = None
self.added_frame_info_label_placed = False
self.downloading_frame_info_label_placed = False
self.downloaded_frame_info_label_placed = False
self.videos_status_count_label = None
self.context_menu = None
self.settings_panel = None
self.settings_btn = None
self.logo_frame = None
self.logo_label = None
self.tray_menu = None
self.is_settings_open = False
self.is_in_full_screen_mode = False
self.root_geometry = ""
self.is_maximized = False
def create_widgets(self) -> None:
"""
Creates and initializes all the GUI widgets for the application.
This method sets up various widgets such as entry fields, radio buttons, buttons, scrollable frames, labels,
and context menus. It also creates the settings panel and logo frame for the application.
"""
self.url_entry = ctk.CTkEntry(master=self, placeholder_text="Enter Youtube URL")
self.video_radio_btn = ctk.CTkRadioButton(
master=self,
text="Video",
height=18,
command=lambda: self.select_download_mode("video")
)
self.video_radio_btn.select()
self.playlist_radio_btn = ctk.CTkRadioButton(
master=self,
text="Playlist",
command=lambda: self.select_download_mode("playlist")
)
self.add_url_btn = ctk.CTkButton(
master=self,
text="Add +",
border_width=2,
command=self.add_video_playlist
)
self.added_content_scroll_frame = ctk.CTkScrollableFrame(master=self)
self.downloading_content_scroll_frame = ctk.CTkScrollableFrame(master=self)
self.downloaded_content_scroll_frame = ctk.CTkScrollableFrame(master=self)
self.navigate_added_btn = ctk.CTkButton(
master=self,
text="Added",
command=lambda: self.place_frame(self.added_content_scroll_frame, "added")
)
self.navigate_downloading_btn = ctk.CTkButton(
master=self,
text="Downloading",
command=lambda: self.place_frame(self.downloading_content_scroll_frame, "downloading")
)
self.navigate_downloaded_btn = ctk.CTkButton(
master=self,
text="Downloaded",
command=lambda: self.place_frame(self.downloaded_content_scroll_frame, "downloaded")
)
self.added_frame_info_label = ctk.CTkLabel(
master=self,
text="Added videos & playlists will be display here.",
)
self.downloading_frame_info_label = ctk.CTkLabel(
master=self,
text="Downloading videos & playlists will be display here.",
)
self.downloaded_frame_info_label = ctk.CTkLabel(
master=self,
text="Downloaded videos & playlists will be display here.",
)
self.videos_status_count_label = ctk.CTkLabel(
text="Loading : 0 | Downloading : 0",
master=self
)
self.settings_panel = SettingPanel(
master=self,
theme_settings_change_callback=self.update_appearance_settings,
general_settings_change_callback=self.update_general_settings,
restart_callback=self.restart
)
self.settings_btn = ctk.CTkButton(
master=self,
text="⚡",
border_spacing=0,
hover=False,
command=self.open_settings
)
self.context_menu = ContextMenu(
master=self,
options_texts=["select_all", "cut", "copy", "paste"],
options_commands=[self.select_all_url, self.cut_url, self.copy_url, self.paste_url]
)
self.logo_frame = ctk.CTkFrame(master=self)
self.logo_label = ctk.CTkLabel(master=self.logo_frame, text="⚡")
def select_all_url(self) -> None:
"""
Selects all text in the URL entry field.
"""
self.url_entry.focus()
pyautogui.hotkey("ctrl", "a")
self.context_menu.place_forget()
def cut_url(self) -> None:
"""
Cuts text from the URL entry field.
"""
self.url_entry.focus()
pyautogui.hotkey("ctrl", "x")
self.context_menu.place_forget()
def copy_url(self) -> None:
"""
Copies text from the URL entry field.
"""
self.url_entry.focus()
pyautogui.hotkey("ctrl", "c")
self.context_menu.place_forget()
def paste_url(self) -> None:
"""
Pastes text into the URL entry field.
"""
self.url_entry.focus()
pyautogui.hotkey("ctrl", "v")
self.context_menu.place_forget()
def place_forget_nav_frames(self) -> None:
"""
Hides the navigation frames for added, downloading, and downloaded content.
"""
self.added_content_scroll_frame.place_forget()
self.downloading_content_scroll_frame.place_forget()
self.downloaded_content_scroll_frame.place_forget()
def place_forget_nav_labels(self) -> None:
"""
Hides the navigation labels for added, downloading, and downloaded content.
"""
self.added_frame_info_label_placed = False
self.downloading_frame_info_label_placed = False
self.downloaded_frame_info_label_placed = False
self.added_frame_info_label.place_forget()
self.downloading_frame_info_label.place_forget()
self.downloaded_frame_info_label.place_forget()
def place_nav_label(self, frame_name: str) -> None:
"""
Places the navigation label for the specified frame in the center of the main window.
Args:
frame_name (str): The name of the frame ('added', 'downloading', or 'downloaded').
"""
self.place_forget_nav_labels()
if frame_name == "added" and self.is_content_added is not True:
self.added_frame_info_label_placed = True
self.added_frame_info_label.place(y=self.winfo_height() / 2 + 45, x=self.winfo_width() / 2, anchor="center")
elif frame_name == "downloading" and self.is_content_downloading is not True:
self.downloading_frame_info_label_placed = True
self.downloading_frame_info_label.place(
y=self.winfo_height() / 2 + 45,
x=self.winfo_width() / 2,
anchor="center"
)
elif frame_name == "downloaded" and self.is_content_downloaded is not True:
self.downloaded_frame_info_label_placed = True
self.downloaded_frame_info_label.place(
y=self.winfo_height() / 2 + 45,
x=self.winfo_width() / 2,
anchor="center"
)
def place_frame(self, frame: ctk.CTkScrollableFrame, frame_name: str) -> None:
"""
Places the specified scrollable frame in the main window and updates the navigation label.
Args:
frame (ctk.CTkScrollableFrame): The scrollable frame to be placed.
frame_name (str): The name of the frame ('added', 'downloading', or 'downloaded').
"""
self.place_forget_nav_frames()
frame.place(y=90 * AppearanceSettings.settings["scale_r"], x=10)
self.place_nav_label(frame_name)
def place_widgets(self) -> None:
"""
Places all the GUI widgets in their respective positions within the main window.
This method sets the position of various widgets such as buttons, entry fields, radio buttons, labels,
and scrollable frames within the main window based on a predetermined layout.
"""
scale = AppearanceSettings.settings["scale_r"]
self.settings_btn.place(x=-5, y=4)
self.url_entry.place(x=43 * scale, y=4)
self.add_url_btn.place(y=4)
self.video_radio_btn.place(y=5)
self.playlist_radio_btn.place(y=25 * scale)
self.navigate_added_btn.place(y=50 * scale, x=10)
self.navigate_downloading_btn.place(y=50 * scale)
self.navigate_downloaded_btn.place(y=50 * scale)
self.place_frame(self.added_content_scroll_frame, "added")
self.videos_status_count_label.place(x=10, rely=1, y=-20 * scale)
self.logo_label.place(relx=0.5, rely=0.5, anchor="center")
def set_widgets_fonts(self) -> None:
"""
Sets the fonts for various GUI widgets.
This method configures the font settings for different GUI widgets such as entry fields, buttons, labels, etc.,
based on a predetermined font style and size.
"""
scale = AppearanceSettings.settings["scale_r"]
self.url_entry.configure(
font=ctk.CTkFont(
family="Segoe UI",
size=int(16 * scale),
weight="normal",
slant="italic",
underline=True
)
)
self.video_radio_btn.configure(font=("Segoe UI", 12 * scale, "bold"))
self.playlist_radio_btn.configure(font=("Segoe UI", 12 * scale, "bold"))
self.add_url_btn.configure(font=("Segoe UI", 15 * scale, "bold"))
font_style_1 = ctk.CTkFont(
family="Comic Sans MS",
size=int(16 * scale),
weight="bold",
slant="italic"
)
self.added_frame_info_label.configure(font=font_style_1)
self.downloading_frame_info_label.configure(font=font_style_1)
self.downloaded_frame_info_label.configure(font=font_style_1)
font_style_2 = ("Segoe UI", 15 * scale, "bold")
self.navigate_added_btn.configure(font=font_style_2)
self.navigate_downloading_btn.configure(font=font_style_2)
self.navigate_downloaded_btn.configure(font=font_style_2)
self.settings_btn.configure(font=("arial", 25 * scale, "normal"))
self.context_menu.configure(font=("Segoe UI", 13 * scale, "bold"))
self.videos_status_count_label.configure(font=("Segoe UI", 11 * scale, "normal"))
self.logo_label.configure(font=("arial", 50 * scale, "normal"))
def set_widgets_sizes(self) -> None:
"""
Sets the sizes for various GUI widgets.
This method configures the size settings for different GUI widgets such as entry fields, buttons,
radio buttons, etc.,based on a predetermined scale value.
"""
scale = AppearanceSettings.settings["scale_r"]
self.url_entry.configure(height=int(40 * scale))
self.video_radio_btn.configure(
radiobutton_width=int(16 * scale),
radiobutton_height=int(16 * scale),
width=int(60 * scale),
height=int(18 * scale)
)
self.playlist_radio_btn.configure(
radiobutton_width=int(16 * scale),
radiobutton_height=int(16 * scale),
width=int(60 * scale),
height=int(18 * scale)
)
self.add_url_btn.configure(height=int(40 * scale), width=int(100 * scale))
self.navigate_added_btn.configure(height=int(40 * scale))
self.navigate_downloading_btn.configure(height=int(40 * scale))
self.navigate_downloaded_btn.configure(height=int(40 * scale))
self.settings_btn.configure(width=int(30 * scale), height=int(40 * scale))
self.context_menu.configure(
width=int(120 * AppearanceSettings.settings["scale_r"]),
height=int(130 * AppearanceSettings.settings["scale_r"])
)
self.videos_status_count_label.configure(height=int(15 * scale))
def configure_widgets_size(self) -> None:
"""
Configures the size and placement of various GUI widgets based on the current size of the main window.
This method adjusts the size and placement settings for different GUI widgets such as entry fields, buttons,
scrollable frames, etc., based on the current size of the main window. It ensures that the widgets are
appropriately sized and positioned to maintain a visually pleasing layout.
"""
scale = AppearanceSettings.settings["scale_r"]
root_width = self.winfo_width()
root_height = self.winfo_height()
self.url_entry.configure(width=root_width - 250 * scale)
button_margin = int(3 * scale)
nav_button_width = int((root_width - 20 - button_margin * 3) / 3)
self.navigate_added_btn.configure(width=nav_button_width)
self.navigate_downloading_btn.configure(width=nav_button_width)
self.navigate_downloaded_btn.configure(width=nav_button_width)
self.navigate_downloading_btn.place(x=nav_button_width + 10 + button_margin)
self.navigate_downloaded_btn.place(x=nav_button_width * 2 + 10 + button_margin * 2)
self.video_radio_btn.place(x=root_width - 190 * scale)
self.playlist_radio_btn.place(x=root_width - 190 * scale)
self.add_url_btn.place(x=root_width - 110 * scale)
if self.added_frame_info_label_placed:
self.place_nav_label("added")
elif self.downloading_frame_info_label_placed:
self.place_nav_label("downloading")
elif self.downloaded_frame_info_label_placed:
self.place_nav_label("downloaded")
frame_height = root_height - (100 + 15) * scale
frame_width = root_width - 40
self.added_content_scroll_frame.configure(height=frame_height, width=frame_width)
self.downloading_content_scroll_frame.configure(height=frame_height, width=frame_width)
self.downloaded_content_scroll_frame.configure(height=frame_height, width=frame_width)
def set_widgets_texts(self):
self.url_entry.configure(
placeholder_text=LanguageManager.data["enter_youtube_url"]
)
self.video_radio_btn.configure(text=LanguageManager.data["video"])
self.playlist_radio_btn.configure(text=LanguageManager.data["playlist"])
self.add_url_btn.configure(text=LanguageManager.data["add +"])
self.navigate_added_btn.configure(text=LanguageManager.data["added"] + " (0)")
self.navigate_downloading_btn.configure(text=LanguageManager.data["downloading"] + " (0)")
self.navigate_downloaded_btn.configure(text=LanguageManager.data["downloaded"] + " (0)")
self.added_frame_info_label.configure(
text=LanguageManager.data["added_videos_&_playlists_will_be_display_here"]
)
self.downloading_frame_info_label.configure(
text=LanguageManager.data["downloading_videos_&_playlists_will_be_display_here"]
)
self.downloaded_frame_info_label.configure(
text=LanguageManager.data["downloaded_videos_&_playlists_will_be_display_here"]
)
self.videos_status_count_label.configure(
text=f"{LanguageManager.data['loading']} : {LoadManager.queued_load_count + LoadManager.active_load_count}"
f" | "
f"{LanguageManager.data['downloading']} : {DownloadManager.queued_download_count +
DownloadManager.active_download_count}"
)
def update_widgets_text(self):
self.set_widgets_texts()
def set_widgets_accent_color(self) -> None:
"""
Sets the accent color for various GUI widgets.
This method configures the accent color for different GUI widgets such as buttons, radio buttons, labels, etc.,
based on the current accent color setting in the application's appearance settings.
"""
self.settings_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.video_radio_btn.configure(
fg_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.playlist_radio_btn.configure(
fg_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.add_url_btn.configure(
border_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.navigate_added_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.navigate_downloading_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.navigate_downloaded_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.added_frame_info_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.downloading_frame_info_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.downloaded_frame_info_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.logo_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
def set_widgets_colors(self) -> None:
"""
Sets the colors for various GUI widgets.
This method configures the color settings for different GUI widgets such as buttons, entry fields, radio buttons
,labels, etc., based on the current color settings in the application's appearance settings.
"""
self.configure(fg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"])
self.settings_btn.configure(
fg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
hover=False
)
self.url_entry.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
fg_color=AppearanceSettings.settings["url_entry"]["fg_color"]["normal"],
border_color=AppearanceSettings.settings["url_entry"]["border_color"]["normal"],
text_color=AppearanceSettings.settings["url_entry"]["text_color"]["normal"]
)
self.video_radio_btn.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
text_color=AppearanceSettings.settings["url_entry"]["text_color"]["normal"]
)
self.playlist_radio_btn.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
text_color=AppearanceSettings.settings["url_entry"]["text_color"]["normal"]
)
self.add_url_btn.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
fg_color=AppearanceSettings.settings["url_adding_button"]["fg_color"]["normal"],
hover=False
)
self.navigate_added_btn.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
fg_color=AppearanceSettings.settings["navigation_button"]["fg_color"]["normal"],
hover=False
)
self.navigate_downloading_btn.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
fg_color=AppearanceSettings.settings["navigation_button"]["fg_color"]["normal"],
hover=False
)
self.navigate_downloaded_btn.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
fg_color=AppearanceSettings.settings["navigation_button"]["fg_color"]["normal"],
hover=False
)
self.added_content_scroll_frame.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
fg_color=AppearanceSettings.settings["navigation_frame"]["fg_color"]["normal"]
)
self.downloading_content_scroll_frame.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
fg_color=AppearanceSettings.settings["navigation_frame"]["fg_color"]["normal"]
)
self.downloaded_content_scroll_frame.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
fg_color=AppearanceSettings.settings["navigation_frame"]["fg_color"]["normal"]
)
self.added_frame_info_label.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"]
)
self.downloading_frame_info_label.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.downloaded_frame_info_label.configure(
bg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"],
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.videos_status_count_label.configure(
text_color=AppearanceSettings.settings["root"]["text_color"]["normal"]
)
self.logo_frame.configure(
fg_color=AppearanceSettings.settings["root"]["fg_color"]["normal"]
)
def bind_widgets_events(self) -> None:
"""
Binds events to various GUI widgets for handling user interactions.
This method binds different event handlers to GUI widgets such as entry fields, buttons, radio buttons, labels,
etc.,for handling user interactions such as mouse clicks, mouse hover, focus changes, etc. It ensures that
appropriate actions are taken in response to user interactions to maintain the desired functionality and
user experience.
"""
self.url_entry.bind("<Button-3>", self.open_context_menu)
self.url_entry.bind("<Button-2>", self.open_context_menu)
self.bind("<Button-2>", self.close_context_menu)
self.bind("<Button-3>", self.close_context_menu)
self.url_entry.bind("<Button-1>", self.close_context_menu_directly)
self.bind("<Button-1>", self.close_context_menu_directly)
self.bind('<FocusOut>', self.close_context_menu_directly)
self.bind("<Configure>", self.run_geometry_changes_tracker)
def on_mouse_enter_url_entry(_event: tk.Event) -> None:
"""
Event handler for mouse entering the URL entry field.
This function is called when the mouse enters the URL entry field. It changes the appearance settings of
the URL entry field to reflect the hover state, such as modifying foreground color, border color, and
text color, based on the current color settings in the application's appearance settings.
"""
self.url_entry.configure(
fg_color=AppearanceSettings.settings["url_entry"]["fg_color"]["hover"],
border_color=AppearanceSettings.settings["url_entry"]["border_color"]["hover"],
text_color=AppearanceSettings.settings["url_entry"]["text_color"]["hover"]
)
def on_mouse_leave_url_entry(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the URL entry field.
This function is called when the mouse leaves the URL entry field. It reverts the appearance settings of the
URL entry field back to the normal state after hover, restoring the original foreground color, border color,
and text color based on the current color settings in the application's appearance settings.
"""
self.url_entry.configure(
fg_color=AppearanceSettings.settings["url_entry"]["fg_color"]["normal"],
border_color=AppearanceSettings.settings["url_entry"]["border_color"]["normal"],
text_color=AppearanceSettings.settings["url_entry"]["text_color"]["normal"]
)
self.url_entry.bind("<Enter>", on_mouse_enter_url_entry)
self.url_entry.bind("<Leave>", on_mouse_leave_url_entry)
######################################################################################
def on_mouse_enter_settings_btn(_event: tk.Event) -> None:
"""
Event handler for mouse entering the settings button.
This function is called when the mouse enters the settings button. It adjusts the text color of the settings
button to reflect the hover state, using the accent color defined in the application's appearance settings.
"""
self.settings_btn.configure(text_color=AppearanceSettings.settings["root"]["accent_color"]["hover"])
def on_mouse_leave_settings_btn(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the settings button.
This function is called when the mouse leaves the settings button. It resets the text color of the settings
button to its normal state, using the accent color defined in the application's appearance settings.
"""
self.settings_btn.configure(text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"])
self.settings_btn.bind("<Enter>", on_mouse_enter_settings_btn)
self.settings_btn.bind("<Leave>", on_mouse_leave_settings_btn)
######################################################################################
def on_mouse_enter_video_radio_btn(_event: tk.Event) -> None:
"""
Event handler for mouse entering the video radio button.
This function is called when the mouse enters the video radio button. It adjusts the text color and
foreground color of the video radio button to reflect the hover state, using the colors defined in
the application's appearance settings.
"""
self.video_radio_btn.configure(
text_color=AppearanceSettings.settings["url_entry"]["text_color"]["hover"],
fg_color=AppearanceSettings.settings["root"]["accent_color"]["hover"]
)
def on_mouse_leave_video_radio_btn(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the video radio button.
This function is called when the mouse leaves the video radio button. It resets the text color and
foreground color of the video radio button to their normal states, using the colors defined in the
application's appearance settings.
"""
self.video_radio_btn.configure(
text_color=AppearanceSettings.settings["url_entry"]["text_color"]["normal"],
fg_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.video_radio_btn.bind("<Enter>", on_mouse_enter_video_radio_btn)
self.video_radio_btn.bind("<Leave>", on_mouse_leave_video_radio_btn)
######################################################################################
def on_mouse_enter_playlist_radio_btn(_event: tk.Event) -> None:
"""
Event handler for mouse entering the playlist radio button.
This function is called when the mouse enters the playlist radio button. It adjusts the text color and
foreground color of the playlist radio button to reflect the hover state, using the colors defined in
the application's appearance settings.
"""
self.playlist_radio_btn.configure(
text_color=AppearanceSettings.settings["url_entry"]["text_color"]["hover"],
fg_color=AppearanceSettings.settings["root"]["accent_color"]["hover"]
)
def on_mouse_leave_playlist_radio_btn(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the playlist radio button.
This function is called when the mouse leaves the playlist radio button. It resets the text color and
foreground color of the playlist radio button to their normal states, using the colors defined in the
application's appearance settings.
"""
self.playlist_radio_btn.configure(
text_color=AppearanceSettings.settings["url_entry"]["text_color"]["normal"],
fg_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.playlist_radio_btn.bind("<Enter>", on_mouse_enter_playlist_radio_btn)
self.playlist_radio_btn.bind("<Leave>", on_mouse_leave_playlist_radio_btn)
######################################################################################
def on_mouse_enter_add_video_playlist_btn(_event: tk.Event) -> None:
"""
Event handler for mouse entering the add video/playlist button.
This function is called when the mouse enters the add video/playlist button. It adjusts the border color,
text color, and foreground color of the button to reflect the hover state, using the colors defined in the
application's appearance settings.
"""
self.add_url_btn.configure(
border_color=AppearanceSettings.settings["root"]["accent_color"]["hover"],
text_color=AppearanceSettings.settings["root"]["accent_color"]["hover"],
fg_color=AppearanceSettings.settings["url_adding_button"]["fg_color"]["hover"]
)
def on_mouse_leave_add_video_playlist_btn(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the add video/playlist button.
This function is called when the mouse leaves the add video/playlist button. It resets the border color,
text color, and foreground color of the button to their normal states, using the colors defined in
the application's appearance settings.
"""
self.add_url_btn.configure(
border_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
fg_color=AppearanceSettings.settings["url_adding_button"]["fg_color"]["normal"]
)
self.add_url_btn.bind("<Enter>", on_mouse_enter_add_video_playlist_btn)
self.add_url_btn.bind("<Leave>", on_mouse_leave_add_video_playlist_btn)
######################################################################################
def on_mouse_enter_navigate_added_frame_btn(_event: tk.Event) -> None:
"""
Event handler for mouse entering the navigate added frame button.
This function is called when the mouse enters the navigate added frame button. It adjusts the text color and
foreground color of the button to reflect the hover state, using the colors defined in the
application's appearance settings.
"""
self.navigate_added_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["hover"],
fg_color=AppearanceSettings.settings["navigation_button"]["fg_color"]["hover"]
)
def on_mouse_leave_navigate_added_frame_btn(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the navigate added frame button.
This function is called when the mouse leaves the navigate added frame button. It resets the text color and
foreground color of the button to their normal states, using the colors defined in the application's
appearance settings.
"""
self.navigate_added_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
fg_color=AppearanceSettings.settings["navigation_button"]["fg_color"]["normal"]
)
self.navigate_added_btn.bind("<Enter>", on_mouse_enter_navigate_added_frame_btn)
self.navigate_added_btn.bind("<Leave>", on_mouse_leave_navigate_added_frame_btn)
######################################################################################
def on_mouse_enter_navigate_downloading_frame_btn(_event: tk.Event) -> None:
"""
Event handler for mouse entering the navigate downloading frame button.
This function adjusts the text color and foreground color of the navigate downloading frame button to
reflect the hover state when the mouse enters the button.The colors are obtained from the application's
appearance settings for the hover state.
Parameters:
_event (tk.Event): The event object.
"""
self.navigate_downloading_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["hover"],
fg_color=AppearanceSettings.settings["navigation_button"]["fg_color"]["hover"]
)
def on_mouse_leave_navigate_downloading_frame_btn(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the navigate downloading frame button.
This function resets the text color and foreground color of the navigate downloading frame button to their
normal states when the mouse leaves the button.The colors are obtained from the application's appearance
settings for the normal state.
Parameters:
_event (tk.Event): The event object.
"""
self.navigate_downloading_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
fg_color=AppearanceSettings.settings["navigation_button"]["fg_color"]["normal"]
)
self.navigate_downloading_btn.bind("<Enter>", on_mouse_enter_navigate_downloading_frame_btn)
self.navigate_downloading_btn.bind("<Leave>", on_mouse_leave_navigate_downloading_frame_btn)
######################################################################################
def on_mouse_enter_navigate_downloaded_frame_btn(_event: tk.Event) -> None:
"""
Event handler for mouse entering the navigate downloaded frame button.
This function adjusts the text color and foreground color of the navigate downloaded frame button to reflect
the hover state when the mouse enters the button.The colors are obtained from the application's appearance
settings for the hover state.
Parameters:
_event (tk.Event): The event object.
"""
self.navigate_downloaded_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["hover"],
fg_color=AppearanceSettings.settings["navigation_button"]["fg_color"]["hover"]
)
def on_mouse_leave_navigate_downloaded_frame_btn(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the navigate downloaded frame button.
This function resets the text color and foreground color of the navigate downloaded frame button to their
normal states when the mouse leaves the button. The colors are obtained from the application's appearance
settings for the normal state.
Parameters:
_event (tk.Event): The event object.
"""
self.navigate_downloaded_btn.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"],
fg_color=AppearanceSettings.settings["navigation_button"]["fg_color"]["normal"]
)
self.navigate_downloaded_btn.bind("<Enter>", on_mouse_enter_navigate_downloaded_frame_btn)
self.navigate_downloaded_btn.bind("<Leave>", on_mouse_leave_navigate_downloaded_frame_btn)
#######################################################################################
def on_mouse_enter_added_frame_info_label(_event: tk.Event) -> None:
"""
Event handler for mouse entering the added frame information label.
This function adjusts the text color of the added frame information label to reflect the hover state when
the mouse enters the label. The color is obtained from the application's appearance settings
for the hover state.
Parameters:
_event (tk.Event): The event object.
"""
self.added_frame_info_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["hover"]
)
def on_mouse_leave_added_frame_info_label(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the added frame information label.
This function resets the text color of the added frame information label to its normal state when the mouse
leaves the label. The color is obtained from the application's appearance settings for the normal state.
Parameters:
_event (tk.Event): The event object.
"""
self.added_frame_info_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.added_frame_info_label.bind("<Enter>", on_mouse_enter_added_frame_info_label)
self.added_frame_info_label.bind("<Leave>", on_mouse_leave_added_frame_info_label)
#######################################################################################
def on_mouse_enter_downloading_frame_info_label(_event: tk.Event) -> None:
"""
Event handler for mouse entering the downloading frame information label.
This function adjusts the text color of the downloading frame information label to reflect the hover state
when the mouse enters the label. The color is obtained from the application's appearance settings
for the hover state.
Parameters:
_event (tk.Event): The event object.
"""
self.downloading_frame_info_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["hover"]
)
def on_mouse_leave_downloading_frame_info_label(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the downloading frame information label.
This function resets the text color of the downloading frame information label to its normal state when the
mouse leaves the label. The color is obtained from the application's appearance settings for
the normal state.
Parameters:
_event (tk.Event): The event object.
"""
self.downloading_frame_info_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.downloading_frame_info_label.bind("<Enter>", on_mouse_enter_downloading_frame_info_label)
self.downloading_frame_info_label.bind("<Leave>", on_mouse_leave_downloading_frame_info_label)
#######################################################################################
def on_mouse_enter_downloaded_frame_info_label(_event: tk.Event) -> None:
"""
Event handler for mouse entering the downloaded frame information label.
This function adjusts the text color of the downloaded frame information label to reflect the hover state
when the mouse enters the label. The color is obtained from the application's appearance settings for
the hover state.
Parameters:
_event (tk.Event): The event object.
"""
self.downloaded_frame_info_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["hover"]
)
def mouse_ot_downloaded_frame_info_label(_event: tk.Event) -> None:
"""
Event handler for mouse leaving the downloaded frame information label.
This function resets the text color of the downloaded frame information label to its normal state when the
mouse leaves the label. The color is obtained from the application's appearance settings for the
normal state.
Parameters:
_event (tk.Event): The event object.
"""
self.downloaded_frame_info_label.configure(
text_color=AppearanceSettings.settings["root"]["accent_color"]["normal"]
)
self.downloaded_frame_info_label.bind("<Enter>", on_mouse_enter_downloaded_frame_info_label)
self.downloaded_frame_info_label.bind("<Leave>", mouse_ot_downloaded_frame_info_label)
def bind_keyboard_shortcuts(self):
"""
Bind the keyboards shortcuts.
"""
def toggle_settings(_event):
if self.is_settings_open:
self.close_settings()
else:
self.open_settings()
def close_settings(_event):
if self.is_settings_open:
self.close_settings()
self.bind("<Control-,>", toggle_settings)
self.bind("<Escape>", close_settings)
def choose_download_mode(_event):
if self.selected_download_mode == "video":
self.select_download_mode("playlist")
else:
self.select_download_mode("video")
self.bind("<Control-d>", choose_download_mode)
self.bind("<Control-D>", choose_download_mode)