From a00ed2a932fdb0f3103777ac3eac106701484ca2 Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Wed, 22 Apr 2026 00:52:33 -0600 Subject: Added feature/create-controls --- ui/__pycache__/control_panel.cpython-312.pyc | Bin 39996 -> 42194 bytes ui/__pycache__/main_window.cpython-312.pyc | Bin 25368 -> 25379 bytes ui/control_panel.py | 34 +++++++++++++++++++-- ui/main_window.py | 2 +- .../__pycache__/controls_window.cpython-312.pyc | Bin 0 -> 3269 bytes 5 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 ui/windows/__pycache__/controls_window.cpython-312.pyc diff --git a/ui/__pycache__/control_panel.cpython-312.pyc b/ui/__pycache__/control_panel.cpython-312.pyc index 834c948..6d020f5 100644 Binary files a/ui/__pycache__/control_panel.cpython-312.pyc and b/ui/__pycache__/control_panel.cpython-312.pyc differ diff --git a/ui/__pycache__/main_window.cpython-312.pyc b/ui/__pycache__/main_window.cpython-312.pyc index c5383cb..b528ac2 100644 Binary files a/ui/__pycache__/main_window.cpython-312.pyc and b/ui/__pycache__/main_window.cpython-312.pyc differ diff --git a/ui/control_panel.py b/ui/control_panel.py index d0f8637..efd4f17 100644 --- a/ui/control_panel.py +++ b/ui/control_panel.py @@ -467,7 +467,7 @@ class AnalogOutputControl(ControlWidget): class ControlPanel(QWidget): """ Left panel — output control widgets. - Header has Add button. Each widget has Edit and Remove buttons overlaid. + Header has Add button. Each widget has Edit, Remove, and reorder buttons. """ controls_changed = pyqtSignal() # emitted whenever widgets are added/edited/removed @@ -516,13 +516,24 @@ class ControlPanel(QWidget): # ── Widget management ───────────────────────────────────────────────────── def _make_wrapper(self, widget: ControlWidget, spec) -> QFrame: - """Wrap a ControlWidget with Edit / Remove buttons in the corner.""" + """Wrap a ControlWidget with Edit / Remove / reorder buttons.""" wrapper = QFrame(); wrapper.setObjectName("controlWidgetWrapper") wl = QVBoxLayout(wrapper); wl.setContentsMargins(0, 0, 0, 0); wl.setSpacing(0) wl.addWidget(widget) # Button row below each widget btn_row = QHBoxLayout(); btn_row.setContentsMargins(2, 1, 2, 1) + + up_btn = QPushButton("↑"); up_btn.setObjectName("traceRemoveBtn") + up_btn.setFixedSize(20, 20); up_btn.setToolTip("Move up") + dn_btn = QPushButton("↓"); dn_btn.setObjectName("traceRemoveBtn") + dn_btn.setFixedSize(20, 20); dn_btn.setToolTip("Move down") + + up_btn.clicked.connect(lambda: self._move(spec, -1)) + dn_btn.clicked.connect(lambda: self._move(spec, +1)) + + btn_row.addWidget(up_btn) + btn_row.addWidget(dn_btn) btn_row.addStretch() edit_btn = QPushButton("✎ Edit"); edit_btn.setObjectName("configButton") @@ -581,6 +592,25 @@ class ControlPanel(QWidget): for spec in specs: self._add_widget_from_spec(spec) + def _move(self, spec, direction: int): + """Move a control up (-1) or down (+1) in the list.""" + try: + idx = self._specs.index(spec) + except ValueError: + return + new_idx = idx + direction + if new_idx < 0 or new_idx >= len(self._specs): + return + + self._specs.insert(new_idx, self._specs.pop(idx)) + self._widgets.insert(new_idx, self._widgets.pop(idx)) + + wrapper = self._inner.itemAt(idx).widget() + self._inner.removeWidget(wrapper) + self._inner.insertWidget(new_idx, wrapper) + + self.controls_changed.emit() + # ── Slots ───────────────────────────────────────────────────────────────── def _on_add(self): diff --git a/ui/main_window.py b/ui/main_window.py index a123677..9df7ef7 100644 --- a/ui/main_window.py +++ b/ui/main_window.py @@ -151,8 +151,8 @@ class MainWindow(QMainWindow): self._chart = StripChartWidget(self.engine, self.registry, self.processor) hsplit.addWidget(self._chart) - hsplit.setSizes([260, 1000]) + root.addWidget(hsplit) sb = QStatusBar(); self.setStatusBar(sb) diff --git a/ui/windows/__pycache__/controls_window.cpython-312.pyc b/ui/windows/__pycache__/controls_window.cpython-312.pyc new file mode 100644 index 0000000..d3d59fc Binary files /dev/null and b/ui/windows/__pycache__/controls_window.cpython-312.pyc differ -- cgit v1.2.3