Skip to content

Commit f9da060

Browse files
committed
Added cfg.json, users now can decide to enable mica or not.
1 parent 4816637 commit f9da060

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

src/config.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"mica": "False"}

src/main.py

+33-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from tkinter import BooleanVar, ttk, Label, StringVar, messagebox
22
import tkinter as tk
33
import darkdetect, sv_ttk, ntkutils
4-
import time
54
import calculations as c
65
import webbrowser
6+
import json
77

88
#region functions
99
def aot():
@@ -39,7 +39,7 @@ def btnEqualsInput(event=None):
3939
content.set(result[0])
4040
content2.set(result[1])
4141
if content.get() == 'r u dumb':
42-
x = x + 1
42+
x += 1
4343
if x == 2:
4444
content.set("")
4545
c.calculation = ""
@@ -60,9 +60,15 @@ def btnEqualsInput(event=None):
6060
content.set("")
6161
c.calculation = ""
6262
messagebox.showerror("Error", "FluxCalc will shut down in 5 seconds")
63-
time.sleep(5)
6463
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)
6672
#endregion
6773

6874
#region window
@@ -71,15 +77,31 @@ def btnEqualsInput(event=None):
7177
root.geometry('318x480')
7278
root.title('')
7379
root.iconbitmap(r'icon.ico')
74-
ntkutils.placeappincenter(root)
7580

7681
if darkdetect.theme() == "Dark":
7782
sv_ttk.set_theme("dark")
7883
ntkutils.dark_title_bar(root)
79-
ntkutils.blur_window_background(root)
8084
else:
8185
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+
83105
#endregion
84106

85107
always_on_top = BooleanVar()
@@ -121,7 +143,7 @@ def btnEqualsInput(event=None):
121143
root.bind('<BackSpace>', backspace)
122144
root.bind("1", lambda e:btnClick(1))
123145
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))
125147
root.bind("4", lambda e:btnClick(4))
126148
root.bind("5", lambda e:btnClick(5))
127149
root.bind("6", lambda e:btnClick(6))
@@ -136,4 +158,7 @@ def btnEqualsInput(event=None):
136158
root.bind("=", lambda e:btnEqualsInput())
137159
root.bind("(", lambda e:btnClick("("))
138160
root.bind(")", lambda e:btnClick(")"))
161+
root.bind('<Control-m>', setmica)
162+
#endregion
163+
139164
root.mainloop()

0 commit comments

Comments
 (0)