neraly complete Model of Driving done, but needs tweaking
This commit is contained in:
31
app/app.py
31
app/app.py
@@ -95,18 +95,39 @@ def launch_gui():
|
||||
path = filedialog.askopenfilename(filetypes=[("JSON","*.json"),("All","*.*")])
|
||||
if not path: return
|
||||
with open(path,"r",encoding="utf-8") as f: data = json.load(f)
|
||||
|
||||
# NEU: sowohl altes (flach) als auch neues Format ("sim"/"app") akzeptieren
|
||||
sim_block = data.get("sim") if isinstance(data, dict) else None
|
||||
if sim_block:
|
||||
sim.load_config(sim_block)
|
||||
else:
|
||||
sim.load_config(data)
|
||||
|
||||
# Tabs dürfen zusätzliche eigene Daten ziehen
|
||||
for t in ui_tabs:
|
||||
if hasattr(t, "load_from_config"): t.load_from_config(data)
|
||||
sim.load_config(data)
|
||||
if hasattr(t, "load_from_config"):
|
||||
t.load_from_config(sim_block or data)
|
||||
|
||||
messagebox.showinfo("Simulator", "Konfiguration geladen.")
|
||||
|
||||
|
||||
def do_save():
|
||||
cfg_out = sim.export_config()
|
||||
# NEU: vollständige Sim-Config (inkl. Defaults) + App-Settings bündeln
|
||||
sim_out = sim.export_config()
|
||||
for t in ui_tabs:
|
||||
if hasattr(t, "save_into_config"): t.save_into_config(cfg_out)
|
||||
if hasattr(t, "save_into_config"):
|
||||
t.save_into_config(sim_out)
|
||||
|
||||
out = {
|
||||
"app": cfg, # aktuelle App-Settings (CAN/UI/Logging etc.)
|
||||
"sim": sim_out, # vollständige Modul-Configs (mit Defaults)
|
||||
}
|
||||
|
||||
path = filedialog.asksaveasfilename(defaultextension=".json", filetypes=[("JSON","*.json")])
|
||||
if not path: return
|
||||
with open(path,"w",encoding="utf-8") as f: json.dump(cfg_out, f, indent=2)
|
||||
with open(path,"w",encoding="utf-8") as f: json.dump(out, f, indent=2)
|
||||
messagebox.showinfo("Simulator", "Konfiguration gespeichert.")
|
||||
|
||||
filemenu.add_command(label="Konfiguration laden…", command=do_load)
|
||||
filemenu.add_command(label="Konfiguration speichern…", command=do_save)
|
||||
filemenu.add_separator(); filemenu.add_command(label="Beenden", command=root.destroy)
|
||||
|
Reference in New Issue
Block a user