summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/windows/channels_window.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/ui/windows/channels_window.py b/ui/windows/channels_window.py
index ecc7cbc..3730b12 100644
--- a/ui/windows/channels_window.py
+++ b/ui/windows/channels_window.py
@@ -743,6 +743,10 @@ class DerivedBlock(QFrame):
# Code editor (shown for all kinds — read-only for built-ins)
self._code_grp = QGroupBox("Code")
code_lay = QVBoxLayout(self._code_grp); code_lay.setContentsMargins(6, 4, 6, 4)
+ # Live variable-name hint — updated whenever sources change
+ self._vars_lbl = QLabel("")
+ self._vars_lbl.setObjectName("traceSource"); self._vars_lbl.setWordWrap(True)
+ code_lay.addWidget(self._vars_lbl)
_mono = QFont("IBM Plex Mono, Consolas, Monospace"); _mono.setStyleHint(QFont.StyleHint.Monospace)
self._code = QTextEdit(); self._code.setObjectName("codeEditor")
self._code.setMinimumHeight(90); self._code.setMaximumHeight(180)
@@ -776,6 +780,7 @@ class DerivedBlock(QFrame):
body.setVisible(False)
outer.addWidget(body)
self._body = body
+ self._update_vars_hint()
self._update_visibility()
def _toggle(self):
@@ -792,11 +797,13 @@ class DerivedBlock(QFrame):
for i in range(cb.count()):
if cb.itemData(i) == src:
cb.setCurrentIndex(i); break
+ cb.currentIndexChanged.connect(lambda _: self._update_vars_hint())
rm = QToolButton(); rm.setText("✕"); rm.setObjectName("traceRemoveBtn")
rm.setFixedSize(22, 22); rm.clicked.connect(lambda: self._rm_src(row, cb))
row.addWidget(cb, 1); row.addWidget(rm)
self._src_vlay.addLayout(row)
self._src_combos.append(cb)
+ self._update_vars_hint()
def _rm_src(self, row, cb):
if cb in self._src_combos:
@@ -804,6 +811,20 @@ class DerivedBlock(QFrame):
while row.count():
it = row.takeAt(0)
if it.widget(): it.widget().deleteLater()
+ self._update_vars_hint()
+
+ def _update_vars_hint(self):
+ """Refresh the variable-name hint above the code editor."""
+ if not hasattr(self, "_vars_lbl"):
+ return
+ from core.signal_processor import _make_src_names
+ sources = [cb.currentData() for cb in self._src_combos if cb.currentData()]
+ if not sources:
+ self._vars_lbl.setText("No sources — add sources above to use named variables")
+ return
+ names = _make_src_names(sources)
+ parts = [f"{name} = x[{i}]" for i, name in enumerate(names)]
+ self._vars_lbl.setText("Variables: " + " · ".join(parts))
def _on_kind(self, idx: int):
from ui.code_templates import BUILTIN_TEMPLATES
@@ -815,6 +836,7 @@ class DerivedBlock(QFrame):
if k in _BUILTIN:
# Show the template as a read-only preview
self._code.setPlainText(BUILTIN_TEMPLATES.get(k, ""))
+ self._update_vars_hint()
self._update_visibility()
def _on_wrt_changed(self, idx: int):