persistencia
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"path": "C:/mingw/gitea/python_gui/ROMs",
|
||||||
|
"selected": [
|
||||||
|
"atarilynx",
|
||||||
|
"atarist"
|
||||||
|
]
|
||||||
|
}
|
||||||
+17
-2
@@ -3,7 +3,9 @@ import json
|
|||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import filedialog, messagebox
|
from tkinter import filedialog, messagebox
|
||||||
|
|
||||||
CONFIG_FILE = "config.json"
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
CONFIG_FILE = os.path.join(BASE_DIR, "config.json")
|
||||||
|
|
||||||
|
|
||||||
class DirectorySelectorApp:
|
class DirectorySelectorApp:
|
||||||
def __init__(self, root):
|
def __init__(self, root):
|
||||||
@@ -68,20 +70,33 @@ class DirectorySelectorApp:
|
|||||||
"selected": [self.listbox.get(i) for i in self.listbox.curselection()]
|
"selected": [self.listbox.get(i) for i in self.listbox.curselection()]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print("\n[DEBUG] Intentando guardar configuración...")
|
||||||
|
print("[DEBUG] Ruta del archivo:", os.path.abspath(CONFIG_FILE))
|
||||||
|
print("[DEBUG] Datos a guardar:", data)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(CONFIG_FILE, "w", encoding="utf-8") as f:
|
with open(CONFIG_FILE, "w", encoding="utf-8") as f:
|
||||||
json.dump(data, f, indent=4)
|
json.dump(data, f, indent=4)
|
||||||
|
print("[DEBUG] Guardado correctamente.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print("[DEBUG] ERROR al guardar:", repr(e))
|
||||||
messagebox.showerror("Error", f"No se pudo guardar la configuración:\n{e}")
|
messagebox.showerror("Error", f"No se pudo guardar la configuración:\n{e}")
|
||||||
|
|
||||||
def load_config(self):
|
def load_config(self):
|
||||||
|
print("[DEBUG] Buscando archivo de configuración...")
|
||||||
|
|
||||||
if not os.path.exists(CONFIG_FILE):
|
if not os.path.exists(CONFIG_FILE):
|
||||||
|
print("[DEBUG] No existe config.json, nada que cargar.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
print("[DEBUG] config.json encontrado:", os.path.abspath(CONFIG_FILE))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(CONFIG_FILE, "r", encoding="utf-8") as f:
|
with open(CONFIG_FILE, "r", encoding="utf-8") as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
except Exception:
|
print("[DEBUG] Configuración cargada:", data)
|
||||||
|
except Exception as e:
|
||||||
|
print("[DEBUG] ERROR al cargar:", repr(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
# Restaurar ruta
|
# Restaurar ruta
|
||||||
|
|||||||
Reference in New Issue
Block a user