1
1
from tkinter import BooleanVar , ttk , Label , StringVar , messagebox
2
2
import tkinter as tk
3
3
import darkdetect , sv_ttk , ntkutils
4
- import time
5
4
import calculations as c
6
5
import webbrowser
6
+ import json
7
7
8
8
#region functions
9
9
def aot ():
@@ -39,7 +39,7 @@ def btnEqualsInput(event=None):
39
39
content .set (result [0 ])
40
40
content2 .set (result [1 ])
41
41
if content .get () == 'r u dumb' :
42
- x = x + 1
42
+ x += 1
43
43
if x == 2 :
44
44
content .set ("" )
45
45
c .calculation = ""
@@ -60,9 +60,15 @@ def btnEqualsInput(event=None):
60
60
content .set ("" )
61
61
c .calculation = ""
62
62
messagebox .showerror ("Error" , "FluxCalc will shut down in 5 seconds" )
63
- time .sleep (5 )
64
63
root .destroy ()
65
-
64
+
65
+ def updateConfig ():
66
+ with open ("config.json" , "w" ) as jsonfile :
67
+ json .dump (data , jsonfile )
68
+ jsonfile .close ()
69
+
70
+ with open ("config.json" , "r" ) as config :
71
+ data = json .load (config )
66
72
#endregion
67
73
68
74
#region window
@@ -71,15 +77,31 @@ def btnEqualsInput(event=None):
71
77
root .geometry ('318x480' )
72
78
root .title ('' )
73
79
root .iconbitmap (r'icon.ico' )
74
- ntkutils .placeappincenter (root )
75
80
76
81
if darkdetect .theme () == "Dark" :
77
82
sv_ttk .set_theme ("dark" )
78
83
ntkutils .dark_title_bar (root )
79
- ntkutils .blur_window_background (root )
80
84
else :
81
85
sv_ttk .set_theme ("light" )
82
- ntkutils .blur_window_background (root )
86
+
87
+ def setmica (event = None ):
88
+ if data ['mica' ] == 'True' :
89
+ data ['mica' ] = 'False'
90
+ micaval = "Off"
91
+ else :
92
+ data ['mica' ] = 'True'
93
+ micaval = "On"
94
+
95
+ updateConfig ()
96
+ content2 .set ("Mica: " + micaval )
97
+
98
+ if data ['mica' ] == 'True' :
99
+ ntkutils .blur_window_background (root )
100
+ if darkdetect .theme () == "Dark" :
101
+ ntkutils .dark_title_bar (root )
102
+ else :
103
+ pass
104
+
83
105
#endregion
84
106
85
107
always_on_top = BooleanVar ()
@@ -121,7 +143,7 @@ def btnEqualsInput(event=None):
121
143
root .bind ('<BackSpace>' , backspace )
122
144
root .bind ("1" , lambda e :btnClick (1 ))
123
145
root .bind ("2" , lambda e :btnClick (2 ))
124
- root .bind ("3" , lambda e :btnClick (3 )) #Please ignore this long piece of code :)
146
+ root .bind ("3" , lambda e :btnClick (3 ))
125
147
root .bind ("4" , lambda e :btnClick (4 ))
126
148
root .bind ("5" , lambda e :btnClick (5 ))
127
149
root .bind ("6" , lambda e :btnClick (6 ))
@@ -136,4 +158,7 @@ def btnEqualsInput(event=None):
136
158
root .bind ("=" , lambda e :btnEqualsInput ())
137
159
root .bind ("(" , lambda e :btnClick ("(" ))
138
160
root .bind (")" , lambda e :btnClick (")" ))
161
+ root .bind ('<Control-m>' , setmica )
162
+ #endregion
163
+
139
164
root .mainloop ()
0 commit comments