Preferences: lazy loading on connect, on by default
Off reads the whole app from app.sab when connecting. Read at each connect, so a change takes effect on the next one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+10
-3
@@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it.
|
|||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
|
|
||||||
VERSION = "0.0.0.170"
|
VERSION = "0.0.0.171"
|
||||||
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
|
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
|
||||||
DEFAULT_GRID_SIZE = 10
|
DEFAULT_GRID_SIZE = 10
|
||||||
DEFAULT_ADD_TIMESTAMP = True
|
DEFAULT_ADD_TIMESTAMP = True
|
||||||
@@ -118,6 +118,7 @@ def load_preferences():
|
|||||||
left_pane_width = DEFAULT_LEFT_PANE_WIDTH
|
left_pane_width = DEFAULT_LEFT_PANE_WIDTH
|
||||||
sedona_home = ""
|
sedona_home = ""
|
||||||
trace_dasp = False
|
trace_dasp = False
|
||||||
|
lazy_loading = True
|
||||||
|
|
||||||
if os.path.exists(PROPERTIES_FILE):
|
if os.path.exists(PROPERTIES_FILE):
|
||||||
try:
|
try:
|
||||||
@@ -130,6 +131,7 @@ def load_preferences():
|
|||||||
)
|
)
|
||||||
sedona_home = config.get("Editor", "sedona.home", fallback="").strip()
|
sedona_home = config.get("Editor", "sedona.home", fallback="").strip()
|
||||||
trace_dasp = config.getboolean("Editor", "trace_dasp", fallback=False)
|
trace_dasp = config.getboolean("Editor", "trace_dasp", fallback=False)
|
||||||
|
lazy_loading = config.getboolean("Editor", "lazy_loading", fallback=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@@ -150,7 +152,8 @@ def load_preferences():
|
|||||||
left_pane_width = max(
|
left_pane_width = max(
|
||||||
MIN_ALLOWED_LEFT_PANE_WIDTH, min(MAX_ALLOWED_LEFT_PANE_WIDTH, left_pane_width)
|
MIN_ALLOWED_LEFT_PANE_WIDTH, min(MAX_ALLOWED_LEFT_PANE_WIDTH, left_pane_width)
|
||||||
)
|
)
|
||||||
return sedona_home, grid_size, add_timestamp, box_width, left_pane_width, trace_dasp
|
return (sedona_home, grid_size, add_timestamp, box_width, left_pane_width, trace_dasp,
|
||||||
|
lazy_loading)
|
||||||
|
|
||||||
|
|
||||||
def save_preferences():
|
def save_preferences():
|
||||||
@@ -170,6 +173,7 @@ def save_preferences():
|
|||||||
"box_width": str(BOX_WIDTH),
|
"box_width": str(BOX_WIDTH),
|
||||||
"left_pane_width": str(LEFT_PANE_WIDTH),
|
"left_pane_width": str(LEFT_PANE_WIDTH),
|
||||||
"trace_dasp": str(TRACE_DASP),
|
"trace_dasp": str(TRACE_DASP),
|
||||||
|
"lazy_loading": str(LAZY_LOADING),
|
||||||
}
|
}
|
||||||
with open(PROPERTIES_FILE, "w") as configfile:
|
with open(PROPERTIES_FILE, "w") as configfile:
|
||||||
config.write(configfile)
|
config.write(configfile)
|
||||||
@@ -259,5 +263,8 @@ def base_window_title_live():
|
|||||||
return f"Sedona Live Editor [v{VERSION}] — {device_host}:{device_port}"
|
return f"Sedona Live Editor [v{VERSION}] — {device_host}:{device_port}"
|
||||||
|
|
||||||
|
|
||||||
SEDONA_HOME, GRID_SIZE, ADD_TIMESTAMP, BOX_WIDTH, LEFT_PANE_WIDTH, TRACE_DASP = load_preferences()
|
# LAZY_LOADING: on connect, read components as folders are opened (True) or the whole
|
||||||
|
# app from app.sab first (False). Read at each connect, so a change takes effect on the next.
|
||||||
|
(SEDONA_HOME, GRID_SIZE, ADD_TIMESTAMP, BOX_WIDTH, LEFT_PANE_WIDTH, TRACE_DASP,
|
||||||
|
LAZY_LOADING) = load_preferences()
|
||||||
LAST_PALETTE_KIT = load_last_palette_kit()
|
LAST_PALETTE_KIT = load_last_palette_kit()
|
||||||
|
|||||||
@@ -70,6 +70,9 @@ class DeviceSession:
|
|||||||
self._load_slot_registry(parts)
|
self._load_slot_registry(parts)
|
||||||
|
|
||||||
self.sox_client.load(0)
|
self.sox_client.load(0)
|
||||||
|
if app_state.LAZY_LOADING:
|
||||||
|
self.seed_info = "lazy loading"
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
count = self.seed_from_sab()
|
count = self.seed_from_sab()
|
||||||
self.seed_info = f"app read from app.sab: {count} components"
|
self.seed_info = f"app read from app.sab: {count} components"
|
||||||
|
|||||||
@@ -2699,6 +2699,18 @@ def open_preferences_dialog():
|
|||||||
)
|
)
|
||||||
chk_trace_dasp.grid(row=5, column=1, sticky="w", pady=(0, 15))
|
chk_trace_dasp.grid(row=5, column=1, sticky="w", pady=(0, 15))
|
||||||
|
|
||||||
|
lbl_lazy = ttk.Label(frame_padded, text="Lazy loading on connect?", anchor="w")
|
||||||
|
lbl_lazy.grid(row=6, column=0, sticky="w", pady=(0, 15), padx=(0, 10))
|
||||||
|
|
||||||
|
# Off: the whole app is read from app.sab when connecting. Takes effect on the next.
|
||||||
|
var_lazy_loading = tk.BooleanVar(value=app_state.LAZY_LOADING)
|
||||||
|
chk_lazy_loading = ttk.Checkbutton(
|
||||||
|
frame_padded,
|
||||||
|
text="Yes",
|
||||||
|
variable=var_lazy_loading
|
||||||
|
)
|
||||||
|
chk_lazy_loading.grid(row=6, column=1, sticky="w", pady=(0, 15))
|
||||||
|
|
||||||
def apply_preferences():
|
def apply_preferences():
|
||||||
try:
|
try:
|
||||||
val = int(entry_grid.get().strip())
|
val = int(entry_grid.get().strip())
|
||||||
@@ -2755,6 +2767,7 @@ def open_preferences_dialog():
|
|||||||
app_state.GRID_SIZE = val
|
app_state.GRID_SIZE = val
|
||||||
app_state.ADD_TIMESTAMP = var_timestamp.get()
|
app_state.ADD_TIMESTAMP = var_timestamp.get()
|
||||||
app_state.TRACE_DASP = var_trace_dasp.get()
|
app_state.TRACE_DASP = var_trace_dasp.get()
|
||||||
|
app_state.LAZY_LOADING = var_lazy_loading.get()
|
||||||
app_state.SEDONA_HOME = entry_home.get().strip()
|
app_state.SEDONA_HOME = entry_home.get().strip()
|
||||||
|
|
||||||
app_state.save_preferences()
|
app_state.save_preferences()
|
||||||
@@ -2773,7 +2786,7 @@ def open_preferences_dialog():
|
|||||||
messagebox.showerror("Invalid Input", message, parent=dialog)
|
messagebox.showerror("Invalid Input", message, parent=dialog)
|
||||||
|
|
||||||
btn_save_pref = ttk.Button(frame_padded, text="Apply Changes", command=apply_preferences)
|
btn_save_pref = ttk.Button(frame_padded, text="Apply Changes", command=apply_preferences)
|
||||||
btn_save_pref.grid(row=6, column=1, sticky="e")
|
btn_save_pref.grid(row=7, column=1, sticky="e")
|
||||||
|
|
||||||
if not app_state.SEDONA_HOME:
|
if not app_state.SEDONA_HOME:
|
||||||
entry_home.focus_set()
|
entry_home.focus_set()
|
||||||
|
|||||||
Reference in New Issue
Block a user