Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bugs while using json #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions YEDDA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand Down Expand Up @@ -628,8 +630,8 @@ def renewPressCommand(self):
if self.debug:
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)
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",
"Shortcut map has been updated!\n\n" +
Expand All @@ -650,8 +652,8 @@ def savenewPressCommand(self):
# make sure ending with ".config"
if not self.configFile.endswith(".config"):
self.configFile += ".config"
with open(self.configFile, 'wb') as fp:
json.dump(self.KeyDef2Dic(self.pressCommand), 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",
"Shortcut map has been saved and updated!\n\n"
Expand Down