9
9
from platform import system
10
10
from threading import Thread
11
11
from tkinter import Frame , PhotoImage , Tk , ttk
12
- from tkinter .constants import DISABLED , LEFT , END
12
+ from tkinter .constants import DISABLED , END , LEFT
13
13
from tkinter .filedialog import askopenfile
14
14
15
15
import darkdetect
16
16
import sv_ttk
17
17
from playsound import playsound
18
+
18
19
if system () == "Windows" :
19
20
from win10toast_click import ToastNotifier
20
21
@@ -57,15 +58,17 @@ def seticon(win):
57
58
except tkinter .TclError :
58
59
pass
59
60
60
- def fullredraw (e ):
61
+
62
+ def fullredraw (e ):
61
63
global prev_state
62
- if prev_state == "zoomed" :
63
- app ._dwm_set_window_attribute (app .DWMWA_TRANSITIONS_FORCEDISABLED , 1 )
64
- app .minimize ()
65
- app .restore ()
66
- app ._dwm_set_window_attribute (app .DWMWA_TRANSITIONS_FORCEDISABLED , 0 )
64
+ if prev_state == "zoomed" :
65
+ app ._dwm_set_window_attribute (app .DWMWA_TRANSITIONS_FORCEDISABLED , 1 )
66
+ app .minimize ()
67
+ app .restore ()
68
+ app ._dwm_set_window_attribute (app .DWMWA_TRANSITIONS_FORCEDISABLED , 0 )
67
69
prev_state = app .state ()
68
70
71
+
69
72
seticon (app )
70
73
71
74
# VARIABLES
@@ -244,7 +247,10 @@ def createManagerWindow(saveTimer, current_mins, current_secs, current_hrs):
244
247
manager_window ,
245
248
text = "Ok!" ,
246
249
command = lambda : saveTimer (
247
- timer_sec_input .get (), timer_min_input .get (), timer_hr_input .get (), manager_app_window
250
+ timer_sec_input .get (),
251
+ timer_min_input .get (),
252
+ timer_hr_input .get (),
253
+ manager_app_window ,
248
254
),
249
255
style = "Accent.TButton" ,
250
256
)
@@ -293,10 +299,7 @@ def createSettingsWindow():
293
299
transparency_label .place (x = 23 , y = 73 )
294
300
295
301
pin_label = ttk .Label (
296
- tab_1 ,
297
- text = " Keep app always on top" ,
298
- image = pin_dark ,
299
- compound = LEFT
302
+ tab_1 , text = " Keep app always on top" , image = pin_dark , compound = LEFT
300
303
)
301
304
pin_label .place (x = 23 , y = 123 )
302
305
@@ -322,8 +325,12 @@ def createSettingsWindow():
322
325
default_hours_label = ttk .Label (tab_3 , text = " Default Hours:" ).place (x = 23 , y = 163 )
323
326
324
327
logo_label = ttk .Label (tab_4 , image = logo ).place (x = 50 , y = 30 )
325
- TimerX_Label = ttk .Label (tab_4 , text = "TimerX" , font = ("Arial Rounded MT Bold" , 50 )).place (x = 210 , y = 40 )
326
- version_Label = ttk .Label (tab_4 , text = f"Version: { ver } " , font = ("Segoe UI" , "20" )).place (x = 220 , y = 120 )
328
+ TimerX_Label = ttk .Label (
329
+ tab_4 , text = "TimerX" , font = ("Arial Rounded MT Bold" , 50 )
330
+ ).place (x = 210 , y = 40 )
331
+ version_Label = ttk .Label (
332
+ tab_4 , text = f"Version: { ver } " , font = ("Segoe UI" , "20" )
333
+ ).place (x = 220 , y = 120 )
327
334
328
335
github_btn = ttk .Button (
329
336
tab_4 ,
@@ -406,7 +413,9 @@ def slider_changed(value):
406
413
ontop_button .place (x = 360 , y = 125 )
407
414
408
415
def browse ():
409
- filedialog = askopenfile (mode = "r" , filetypes = [("Audio Files" , ["*.mp3" , "*.wav" ])])
416
+ filedialog = askopenfile (
417
+ mode = "r" , filetypes = [("Audio Files" , ["*.mp3" , "*.wav" ])]
418
+ )
410
419
if not filedialog == None :
411
420
sound_path_entry .delete (0 , END )
412
421
sound_path_entry .insert (1 , filedialog .name )
@@ -458,6 +467,14 @@ def ApplyChanges():
458
467
config ["sound_path" ] = sp
459
468
460
469
setAlwaysOnTop ()
470
+
471
+ saveTimer (
472
+ config ["default_seconds" ],
473
+ config ["default_minutes" ],
474
+ config ["default_hours" ],
475
+ None ,
476
+ )
477
+
461
478
saveTimer (config ["default_seconds" ], config ["default_minutes" ], config ["default_hours" ], None )
462
479
463
480
saveConfig (config )
@@ -494,13 +511,13 @@ def Error(reason, entry, label):
494
511
label .configure (text = "Enter a number above -1" )
495
512
elif reason == "sound" :
496
513
entry .state (["invalid" ])
497
- label .configure (text = "This file doesnt exist." )
514
+ label .configure (text = "This file doesnt exist." )
498
515
499
516
validated = True
500
517
501
518
try :
502
519
void = int (default_secs_entry .get ())
503
- if not void < 60 :
520
+ if not void < 60 :
504
521
validated = False
505
522
Error ("wv" , default_secs_entry , dse_error_lbl )
506
523
if not void > 0 :
@@ -591,6 +608,7 @@ def reset_spe(e):
591
608
sound_path_entry .bind ("<FocusIn>" , reset_spe )
592
609
sound_path_entry .bind ("<KeyRelease>" , reset_spe )
593
610
611
+
594
612
# KEYBINDS
595
613
app .bind ("key-space" , startstopButtonPressed )
596
614
@@ -705,29 +723,38 @@ def sizechanged(e):
705
723
play_button .configure (width = int (app .winfo_width () / 12 ))
706
724
manager_button .configure (width = int (app .winfo_width () / 12 ))
707
725
726
+
708
727
def makeWindowsBlur ():
709
728
from ctypes import windll
710
729
from sys import getwindowsversion
711
- if getwindowsversion ().build >= 22000 :
712
- from win32mica import ApplyMica , MICAMODE
730
+
731
+ if getwindowsversion ().build >= 22000 :
732
+ from win32mica import MICAMODE , ApplyMica
733
+
713
734
app .wm_attributes ("-transparent" , bg_color )
714
735
app .update ()
715
736
if theme == "Dark" :
716
- ApplyMica (HWND = windll .user32 .GetParent (app .winfo_id ()), ColorMode = MICAMODE .DARK )
737
+ ApplyMica (
738
+ HWND = windll .user32 .GetParent (app .winfo_id ()), ColorMode = MICAMODE .DARK
739
+ )
717
740
else :
718
- ApplyMica (HWND = windll .user32 .GetParent (app .winfo_id ()), ColorMode = MICAMODE .LIGHT )
741
+ ApplyMica (
742
+ HWND = windll .user32 .GetParent (app .winfo_id ()), ColorMode = MICAMODE .LIGHT
743
+ )
719
744
else :
720
745
from BlurWindow .blurWindow import GlobalBlur
746
+
721
747
if theme == "Dark" :
722
748
GlobalBlur (
723
749
windll .user32 .GetParent (app .winfo_id ()),
724
750
Acrylic = True ,
725
751
hexColor = "#1c1c1c" ,
726
- Dark = True
752
+ Dark = True ,
727
753
)
728
754
else :
729
755
pass
730
-
756
+
757
+
731
758
# LOAD IMAGES
732
759
theme_dark = PhotoImage (file = "./assets/images/dark/dark_theme.png" )
733
760
theme_light = PhotoImage (file = "./assets/images/light/dark_theme.png" )
@@ -764,15 +791,13 @@ def makeWindowsBlur():
764
791
765
792
app .bind ("<Configure>" , sizechanged )
766
793
767
- app .bind ("<Expose>" , fullredraw )
794
+ app .bind ("<Expose>" , fullredraw )
768
795
769
796
app .wait_visibility ()
770
797
app .attributes ("-alpha" , config ["transperency" ])
771
798
772
799
# UPDATE
773
- app .after (
774
- 500 , Thread (target = checkForUpdates , args = (ver ,)).start
775
- )
800
+ app .after (500 , Thread (target = checkForUpdates , args = (ver ,)).start )
776
801
777
802
# TKINTER MAINLOOP
778
803
app .mainloop ()
0 commit comments