persistencia
This commit is contained in:
+17
-2
@@ -3,7 +3,9 @@ import json
|
||||
import tkinter as tk
|
||||
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:
|
||||
def __init__(self, root):
|
||||
@@ -68,20 +70,33 @@ class DirectorySelectorApp:
|
||||
"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:
|
||||
with open(CONFIG_FILE, "w", encoding="utf-8") as f:
|
||||
json.dump(data, f, indent=4)
|
||||
print("[DEBUG] Guardado correctamente.")
|
||||
except Exception as e:
|
||||
print("[DEBUG] ERROR al guardar:", repr(e))
|
||||
messagebox.showerror("Error", f"No se pudo guardar la configuración:\n{e}")
|
||||
|
||||
def load_config(self):
|
||||
print("[DEBUG] Buscando archivo de configuración...")
|
||||
|
||||
if not os.path.exists(CONFIG_FILE):
|
||||
print("[DEBUG] No existe config.json, nada que cargar.")
|
||||
return
|
||||
|
||||
print("[DEBUG] config.json encontrado:", os.path.abspath(CONFIG_FILE))
|
||||
|
||||
try:
|
||||
with open(CONFIG_FILE, "r", encoding="utf-8") as 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
|
||||
|
||||
# Restaurar ruta
|
||||
|
||||
Reference in New Issue
Block a user