From c7cbd55ba2ac4af3c4b417c31c98a85e5cb53331 Mon Sep 17 00:00:00 2001 From: ethan-chew Date: Tue, 8 Feb 2022 11:42:25 +0800 Subject: [PATCH] Renabled Font Multiplier (Autoreset??) --- .data.json | 2 +- toolsUI.py | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.data.json b/.data.json index 4c89cd7..f0d3658 100644 --- a/.data.json +++ b/.data.json @@ -1 +1 @@ -{"fontMultiplier": 1.0, "recentlyOpened": ["Equation of Circle", "Settings"]} \ No newline at end of file +{"fontMultiplier": 1.0, "recentlyOpened": ["Settings", "Parallelogram", "Chemistry", "Chemical Equation", "Mathematics", "Quadratic", "Volume", "Trapezium", "Rectangle/Square", "Circles", "Settings"]} \ No newline at end of file diff --git a/toolsUI.py b/toolsUI.py index 7214874..b765457 100644 --- a/toolsUI.py +++ b/toolsUI.py @@ -36,6 +36,7 @@ def reload(): fontMultiplier = float(extractedData["fontMultiplier"]) reload() +print(fontMultiplier) def ChemicalEquation(self): # Input Data @@ -832,13 +833,17 @@ def Settings(self): def getCurrValue(): tempVal = '{: .2f}'.format(currentVal.get()/30) - file = open(jsonData) - extractedData = json.load(file) - tempJSON = {"fontMultiplier": float(tempVal), "recentlyOpened": extractedData['recentlyOpened']} - json.dump(tempJSON, file) - file.close() - reload() - print(type(tempVal), tempVal) + try: + global extractedData + extractedData = {} + file = open(jsonData, "r") + extractedData = json.load(file) + file.close() + file = open(jsonData, "w+") + tempJSON = {"fontMultiplier": float(tempVal), "recentlyOpened": extractedData['recentlyOpened']} + json.dump(tempJSON, file) + file.close() + except Exception as err: print(err) return tempVal def sliderChanged(event): @@ -861,9 +866,10 @@ def sliderChanged(event): self.fontMulHeader = WrappingLabel(self.mainFrame, text="Font Multiplier", font=(font,int(fontMultiplier*20), 'bold')) self.fontMulHeader.grid(row=0, columnspan=2, sticky = tk.W+tk.E, pady=5) self.fontMulSlider = ttk.Scale(self.mainFrame, from_=0, to=160, length=400, command=sliderChanged, variable=currentVal) - self.fontMulSlider.set(int(fontMultiplier*30)-0.5) + self.fontMulSlider.set(int(fontMultiplier*30)) self.fontMulSlider.grid(row=1, pady=2, columnspan = 5, sticky = tk.W+tk.E) - self.fontMulTxt = WrappingLabel(self.mainFrame, text="Multiplier: {}".format(getCurrValue()), font=(font,int(fontMultiplier*12))) + self.fontMulTxt = WrappingLabel(self.mainFrame, text="Multiplier: ", font=(font,int(fontMultiplier*12))) + self.fontMulTxt.config(text="Multiplier: {}".format(getCurrValue())) self.fontMulTxt.grid(row=2, columnspan=2, sticky= tk.W+tk.E) self.mainLabel = WrappingLabel(self.mainFrame, text="Please restart for best results", font=(font,int(fontMultiplier*10))) self.mainLabel.grid(row=3, columnspan=2, sticky= tk.W+tk.E) \ No newline at end of file