Added inskscape / Added "New" button to the editor
This commit is contained in:
parent
90e4b0fb87
commit
051de86fbe
1 changed files with 26 additions and 8 deletions
34
editor.py
34
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 #######################
|
##################### OPEN BUTTON #######################
|
||||||
|
|
||||||
def on_open(w):
|
def on_open(w):
|
||||||
|
@ -273,13 +298,7 @@ def on_open(w):
|
||||||
with open(dialog.get_filename()) as f:
|
with open(dialog.get_filename()) as f:
|
||||||
loaded_file = json.load(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:
|
for i in win.data_is:
|
||||||
if i in loaded_file and type(win.data_is[i]) == type(loaded_file[i]):
|
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)))
|
updaters[i](loaded_file.get(i, type_min(i)))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
win.data_is[i] = loaded_file.get(i, type_min(i))
|
win.data_is[i] = loaded_file.get(i, type_min(i))
|
||||||
raise()
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
updaters[i](loaded_file.get(i, type_min(i)))
|
updaters[i](loaded_file.get(i, type_min(i)))
|
||||||
|
|
Loading…
Reference in a new issue