From 051de86fbee093625a8340a1b207b170b56e7439 Mon Sep 17 00:00:00 2001 From: jyamihud Date: Thu, 12 May 2022 20:07:56 +0300 Subject: [PATCH] Added inskscape / Added "New" button to the editor --- editor.py | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/editor.py b/editor.py index 45b5877..2fe5647 100644 --- a/editor.py +++ b/editor.py @@ -249,6 +249,31 @@ win.data_is = { } +##################### NEW BUTTON ####################### + +def type_min(i): + if type(win.data_is[i]) == list: + return [] + elif type(win.data_is[i]) == dict: + return {} + elif type(win.data_is[i]) == str: + return "" + +def on_new(w): + + + for i in win.data_is: + + try: + updaters[i](type_min(i)) + except Exception as e: + win.data_is[i] = type_min(i) + +new_button = Gtk.Button("New") +new_button.set_relief(Gtk.ReliefStyle.NONE) +new_button.connect("clicked", on_new) +pannel.pack_start(new_button) + ##################### OPEN BUTTON ####################### def on_open(w): @@ -273,13 +298,7 @@ def on_open(w): with open(dialog.get_filename()) as f: loaded_file = json.load(f) - def type_min(i): - if type(win.data_is[i]) == list: - return [] - elif type(win.data_is[i]) == dict: - return {} - elif type(win.data_is[i]) == str: - return "" + for i in win.data_is: if i in loaded_file and type(win.data_is[i]) == type(loaded_file[i]): @@ -288,7 +307,6 @@ def on_open(w): updaters[i](loaded_file.get(i, type_min(i))) except Exception as e: win.data_is[i] = loaded_file.get(i, type_min(i)) - raise() else: try: updaters[i](loaded_file.get(i, type_min(i)))