From 160f65c95e7877b7069fe2a4b830cca319345cc3 Mon Sep 17 00:00:00 2001 From: Arda Aydin Date: Sun, 18 Oct 2026 08:39:01 +0300 Subject: [PATCH] Preferences: toggle slot numbers on wiresheet, off by default Co-Authored-By: Claude Opus 5.5 --- app_state.py | 10 +++++++--- main.py | 14 +++++++++++++- schema.py | 8 +++++--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app_state.py b/app_state.py index 4636570..26de13a 100644 --- a/app_state.py +++ b/app_state.py @@ -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.172" +VERSION = "0.0.0.173" PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties") DEFAULT_GRID_SIZE = 10 DEFAULT_ADD_TIMESTAMP = True @@ -119,6 +119,7 @@ def load_preferences(): sedona_home = "" trace_dasp = False lazy_loading = True + show_slot_numbers = False if os.path.exists(PROPERTIES_FILE): try: @@ -132,6 +133,7 @@ def load_preferences(): sedona_home = config.get("Editor", "sedona.home", fallback="").strip() trace_dasp = config.getboolean("Editor", "trace_dasp", fallback=False) lazy_loading = config.getboolean("Editor", "lazy_loading", fallback=True) + show_slot_numbers = config.getboolean("Editor", "show_slot_numbers", fallback=False) except Exception: pass else: @@ -153,7 +155,7 @@ def load_preferences(): 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, - lazy_loading) + lazy_loading, show_slot_numbers) def save_preferences(): @@ -174,6 +176,7 @@ def save_preferences(): "left_pane_width": str(LEFT_PANE_WIDTH), "trace_dasp": str(TRACE_DASP), "lazy_loading": str(LAZY_LOADING), + "show_slot_numbers": str(SHOW_SLOT_NUMBERS), } with open(PROPERTIES_FILE, "w") as configfile: config.write(configfile) @@ -265,6 +268,7 @@ def base_window_title_live(): # 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. +# SHOW_SLOT_NUMBERS: prefix wiresheet slot rows with their slot id ("03. out"). (SEDONA_HOME, GRID_SIZE, ADD_TIMESTAMP, BOX_WIDTH, LEFT_PANE_WIDTH, TRACE_DASP, - LAZY_LOADING) = load_preferences() + LAZY_LOADING, SHOW_SLOT_NUMBERS) = load_preferences() LAST_PALETTE_KIT = load_last_palette_kit() diff --git a/main.py b/main.py index 76fc0f5..03ee601 100644 --- a/main.py +++ b/main.py @@ -2711,6 +2711,17 @@ def open_preferences_dialog(): ) chk_lazy_loading.grid(row=6, column=1, sticky="w", pady=(0, 15)) + lbl_slot_numbers = ttk.Label(frame_padded, text="Slot numbers on wiresheet?", anchor="w") + lbl_slot_numbers.grid(row=7, column=0, sticky="w", pady=(0, 15), padx=(0, 10)) + + var_slot_numbers = tk.BooleanVar(value=app_state.SHOW_SLOT_NUMBERS) + chk_slot_numbers = ttk.Checkbutton( + frame_padded, + text="Yes", + variable=var_slot_numbers + ) + chk_slot_numbers.grid(row=7, column=1, sticky="w", pady=(0, 15)) + def apply_preferences(): try: val = int(entry_grid.get().strip()) @@ -2768,6 +2779,7 @@ def open_preferences_dialog(): app_state.ADD_TIMESTAMP = var_timestamp.get() app_state.TRACE_DASP = var_trace_dasp.get() app_state.LAZY_LOADING = var_lazy_loading.get() + app_state.SHOW_SLOT_NUMBERS = var_slot_numbers.get() app_state.SEDONA_HOME = entry_home.get().strip() app_state.save_preferences() @@ -2786,7 +2798,7 @@ def open_preferences_dialog(): messagebox.showerror("Invalid Input", message, parent=dialog) btn_save_pref = ttk.Button(frame_padded, text="Apply Changes", command=apply_preferences) - btn_save_pref.grid(row=7, column=1, sticky="e") + btn_save_pref.grid(row=8, column=1, sticky="e") if not app_state.SEDONA_HOME: entry_home.focus_set() diff --git a/schema.py b/schema.py index 94f06bc..729c52e 100644 --- a/schema.py +++ b/schema.py @@ -353,9 +353,11 @@ def get_slots_for_type(type_str, linked_slots=()): if "c" in slot_data["flags"]: continue - # Format to double digits (e.g., 00, 01, 02) - padded_id = f"{slot_data['slot_id']:02d}" - display_label = f"{padded_id}. {slot_name}" + # Format to double digits (e.g., 00, 01, 02), unless turned off in Preferences + if app_state.SHOW_SLOT_NUMBERS: + display_label = f"{slot_data['slot_id']:02d}. {slot_name}" + else: + display_label = slot_name # Keep structural name unchanged for XML lookup inside comp, but pass display label slots_list.append((slot_name, display_label))