Palette: reopen the last chosen kit instead of starting empty

The chosen kit is remembered in editor.properties [Palette]; a file without it
opens on its first kit. Saving preferences now keeps the other sections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-06 21:14:30 +03:00
co-authored by Claude Opus 5.5
parent b63655462f
commit bc4e28d3f7
2 changed files with 45 additions and 5 deletions
+36 -2
View File
@@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it.
import configparser
import os
VERSION = "0.0.0.153"
VERSION = "0.0.0.154"
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
DEFAULT_GRID_SIZE = 10
DEFAULT_ADD_TIMESTAMP = True
@@ -148,8 +148,15 @@ def load_preferences():
def save_preferences():
"""Writes the current preference values back to editor.properties."""
"""Writes the current preference values back to editor.properties.
The file is read first so the sections other code owns ([Device], [Palette]) survive.
"""
config = configparser.ConfigParser()
try:
config.read(PROPERTIES_FILE)
except Exception:
pass
config["Editor"] = {
"sedona.home": SEDONA_HOME,
"grid_size": str(GRID_SIZE),
@@ -162,6 +169,32 @@ def save_preferences():
config.write(configfile)
def load_last_palette_kit():
"""The kit the palette dropdown showed last, or "" when none was ever chosen."""
config = configparser.ConfigParser()
try:
config.read(PROPERTIES_FILE)
return config.get("Palette", "kit", fallback="").strip()
except Exception:
return ""
def save_last_palette_kit(kit_name):
"""Remembers the palette's kit so the next start, or a kit refresh, reopens it."""
global LAST_PALETTE_KIT
LAST_PALETTE_KIT = kit_name
config = configparser.ConfigParser()
try:
config.read(PROPERTIES_FILE)
if "Palette" not in config:
config["Palette"] = {}
config["Palette"]["kit"] = kit_name
with open(PROPERTIES_FILE, "w") as configfile:
config.write(configfile)
except Exception:
pass
def base_window_title():
"""The window title with no file context, which handlers extend with their own suffix."""
return f"Sedona SAX Offline Program Editor [v{VERSION}]"
@@ -221,3 +254,4 @@ def base_window_title_live():
SEDONA_HOME, GRID_SIZE, ADD_TIMESTAMP, BOX_WIDTH, LEFT_PANE_WIDTH, TRACE_DASP = load_preferences()
LAST_PALETTE_KIT = load_last_palette_kit()