Preferences: toggle slot numbers on wiresheet, off by default
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+7
-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.172"
|
VERSION = "0.0.0.173"
|
||||||
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
|
||||||
@@ -119,6 +119,7 @@ def load_preferences():
|
|||||||
sedona_home = ""
|
sedona_home = ""
|
||||||
trace_dasp = False
|
trace_dasp = False
|
||||||
lazy_loading = True
|
lazy_loading = True
|
||||||
|
show_slot_numbers = False
|
||||||
|
|
||||||
if os.path.exists(PROPERTIES_FILE):
|
if os.path.exists(PROPERTIES_FILE):
|
||||||
try:
|
try:
|
||||||
@@ -132,6 +133,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)
|
lazy_loading = config.getboolean("Editor", "lazy_loading", fallback=True)
|
||||||
|
show_slot_numbers = config.getboolean("Editor", "show_slot_numbers", fallback=False)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@@ -153,7 +155,7 @@ def load_preferences():
|
|||||||
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)
|
lazy_loading, show_slot_numbers)
|
||||||
|
|
||||||
|
|
||||||
def save_preferences():
|
def save_preferences():
|
||||||
@@ -174,6 +176,7 @@ def save_preferences():
|
|||||||
"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),
|
"lazy_loading": str(LAZY_LOADING),
|
||||||
|
"show_slot_numbers": str(SHOW_SLOT_NUMBERS),
|
||||||
}
|
}
|
||||||
with open(PROPERTIES_FILE, "w") as configfile:
|
with open(PROPERTIES_FILE, "w") as configfile:
|
||||||
config.write(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
|
# 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.
|
# 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,
|
(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()
|
LAST_PALETTE_KIT = load_last_palette_kit()
|
||||||
|
|||||||
@@ -2711,6 +2711,17 @@ def open_preferences_dialog():
|
|||||||
)
|
)
|
||||||
chk_lazy_loading.grid(row=6, column=1, sticky="w", pady=(0, 15))
|
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():
|
def apply_preferences():
|
||||||
try:
|
try:
|
||||||
val = int(entry_grid.get().strip())
|
val = int(entry_grid.get().strip())
|
||||||
@@ -2768,6 +2779,7 @@ def open_preferences_dialog():
|
|||||||
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.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.SEDONA_HOME = entry_home.get().strip()
|
||||||
|
|
||||||
app_state.save_preferences()
|
app_state.save_preferences()
|
||||||
@@ -2786,7 +2798,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=7, column=1, sticky="e")
|
btn_save_pref.grid(row=8, column=1, sticky="e")
|
||||||
|
|
||||||
if not app_state.SEDONA_HOME:
|
if not app_state.SEDONA_HOME:
|
||||||
entry_home.focus_set()
|
entry_home.focus_set()
|
||||||
|
|||||||
@@ -353,9 +353,11 @@ def get_slots_for_type(type_str, linked_slots=()):
|
|||||||
if "c" in slot_data["flags"]:
|
if "c" in slot_data["flags"]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Format to double digits (e.g., 00, 01, 02)
|
# Format to double digits (e.g., 00, 01, 02), unless turned off in Preferences
|
||||||
padded_id = f"{slot_data['slot_id']:02d}"
|
if app_state.SHOW_SLOT_NUMBERS:
|
||||||
display_label = f"{padded_id}. {slot_name}"
|
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
|
# Keep structural name unchanged for XML lookup inside comp, but pass display label
|
||||||
slots_list.append((slot_name, display_label))
|
slots_list.append((slot_name, display_label))
|
||||||
|
|||||||
Reference in New Issue
Block a user