From b5d23b096ab42c5d86d1a1731128bab746e596eb Mon Sep 17 00:00:00 2001 From: nsbb Date: Wed, 4 Jan 2023 17:47:29 +0900 Subject: [PATCH 1/2] fix bugs while using json --- YEDDA.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/YEDDA.py b/YEDDA.py index 225c497..79d8d20 100644 --- a/YEDDA.py +++ b/YEDDA.py @@ -271,6 +271,8 @@ def readConfig(self): self.pressCommand = [] with open(self.configFile, 'r') as fp: config_dict = json.load(fp) + if type(config_dict) is str: + config_dcit = json.loads(config_dict) for index,entity in config_dict.items(): self.pressCommand.append(KeyDef(index,entity)) for key, color in zip(self.pressCommand, all_colors()): @@ -629,7 +631,7 @@ def renewPressCommand(self): print("Action Track: renewPressCommand") self.pressCommand = self.keymap_frame.read_keymap() with open(self.configFile, 'wb') as fp: - json.dump(self.KeyDef2Dic(self.pressCommand), fp) + json.dump(json.dumps(self.KeyDef2Dic()), fp) self.keymap_frame.update_keymap(self.pressCommand) messagebox.showinfo("Remap Notification", "Shortcut map has been updated!\n\n" + @@ -651,7 +653,7 @@ def savenewPressCommand(self): if not self.configFile.endswith(".config"): self.configFile += ".config" with open(self.configFile, 'wb') as fp: - json.dump(self.KeyDef2Dic(self.pressCommand), fp) + json.dump(json.dumps(self.KeyDef2Dic()), fp) self.keymap_frame.update_keymap(self.pressCommand) messagebox.showinfo("Save New Map Notification", "Shortcut map has been saved and updated!\n\n" From 5ddf7532199534a3923d9f2282c0824fb99af9dd Mon Sep 17 00:00:00 2001 From: nsbb Date: Wed, 4 Jan 2023 18:01:20 +0900 Subject: [PATCH 2/2] fix bugs while using json --- YEDDA.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/YEDDA.py b/YEDDA.py index 79d8d20..9a68a4e 100644 --- a/YEDDA.py +++ b/YEDDA.py @@ -630,7 +630,7 @@ def renewPressCommand(self): if self.debug: print("Action Track: renewPressCommand") self.pressCommand = self.keymap_frame.read_keymap() - with open(self.configFile, 'wb') as fp: + with open(self.configFile, 'w') as fp: json.dump(json.dumps(self.KeyDef2Dic()), fp) self.keymap_frame.update_keymap(self.pressCommand) messagebox.showinfo("Remap Notification", @@ -652,7 +652,7 @@ def savenewPressCommand(self): # make sure ending with ".config" if not self.configFile.endswith(".config"): self.configFile += ".config" - with open(self.configFile, 'wb') as fp: + with open(self.configFile, 'w') as fp: json.dump(json.dumps(self.KeyDef2Dic()), fp) self.keymap_frame.update_keymap(self.pressCommand) messagebox.showinfo("Save New Map Notification",