From 543fcaa48e6721865f931961ecbfbeccc2df7fbf Mon Sep 17 00:00:00 2001 From: Yekta Yazar Date: Tue, 16 Sep 2025 11:24:34 -0700 Subject: [PATCH 1/3] addressed two errors. one pyside6 error with active_toggle. And another with curves leaving imprints on old axis after they have been moved --- trace/widgets/control_panel.py | 46 ++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/trace/widgets/control_panel.py b/trace/widgets/control_panel.py index c4eb037e..cfbded8b 100644 --- a/trace/widgets/control_panel.py +++ b/trace/widgets/control_panel.py @@ -1,4 +1,5 @@ import re +import inspect from qtpy import QtGui, QtCore, QtWidgets from qtpy.QtCore import Qt, Slot, QTimer @@ -586,7 +587,9 @@ def set_active(self, state: int | Qt.CheckState): checked = Qt.CheckState(state) == Qt.Checked self.source.setVisible(checked) for i in range(1, self.layout().count()): - self.layout().itemAt(i).widget().active_toggle.setCheckState(state) + widget = self.layout().itemAt(i).widget() + if isinstance(widget, CurveItem): + widget.active_toggle.setCheckState(state) @Slot(int) @Slot(Qt.CheckState) @@ -724,9 +727,26 @@ def remove_curve_item(self, curve_item: "CurveItem", delete_curve: bool = False) from the plot entirely. If False, it will just be unlinked from this axis., by default False. """ - self.plot.plotItem.unlinkDataFromAxis(curve_item.source) - curve_item.curve_deleted.disconnect() - self.layout().removeWidget(curve_item) + old_axis_name = self.source.name + + unlink_method = self.plot.plotItem.unlinkDataFromAxis + + signature = inspect.signature(unlink_method) + + if len(signature.parameters) > 1: + self.plot.plotItem.unlinkDataFromAxis(curve_item.source, old_axis_name) + else: + self.plot.plotItem.unlinkDataFromAxis(curve_item.source) + + axis = self.plot.plotItem.getAxis(old_axis_name) + if axis is not None: + old_view = axis.linkedView() + if old_view is not None and hasattr(old_view, 'removeItem'): + old_view.removeItem(curve_item.source) + + if self.layout().indexOf(curve_item) != -1: + self.layout().removeWidget(curve_item) + curve_item.setParent(None) if delete_curve: curve_item.close() @@ -740,13 +760,25 @@ def add_curve_item(self, curve_item: "CurveItem") -> None: curve_item : CurveItem The CurveItem to be added to this axis. """ + current_axis = getattr(curve_item.source, "y_axis_name", None) + if current_axis and current_axis != self.source.name: + unlink_method = self.plot.plotItem.unlinkDataFromAxis + signature = inspect.signature(unlink_method) + + if len(signature.parameters) > 1 and hasattr(self.plot.plotItem, 'unlinkDataFromAxis'): + self.plot.plotItem.unlinkDataFromAxis(curve_item.source, current_axis) + + if hasattr(self.plot.plotItem, 'linkDataToAxis'): + self.plot.plotItem.linkDataToAxis(curve_item.source, self.source.name) + curve_item.source.y_axis_name = self.source.name - self.plot.plotItem.linkDataToAxis(curve_item.source, self.source.name) - + curve_item.curve_deleted.connect(lambda curve: self.handle_curve_deleted(curve)) curve_item.active_toggle.setCheckState(self.active_toggle.checkState()) - self.layout().removeWidget(curve_item) # in case we're reordering within an AxisItem + if self.layout().indexOf(curve_item) != -1: + self.layout().removeWidget(curve_item) + idx = self.layout().indexOf(self.placeholder) self.layout().insertWidget(idx, curve_item) From c5db5865940848e03142622509b60c01df47cf05 Mon Sep 17 00:00:00 2001 From: Yekta Yazar Date: Tue, 16 Sep 2025 11:25:09 -0700 Subject: [PATCH 2/3] formatting fixes --- trace/widgets/control_panel.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/trace/widgets/control_panel.py b/trace/widgets/control_panel.py index cfbded8b..c828afa6 100644 --- a/trace/widgets/control_panel.py +++ b/trace/widgets/control_panel.py @@ -728,22 +728,22 @@ def remove_curve_item(self, curve_item: "CurveItem", delete_curve: bool = False) from this axis., by default False. """ old_axis_name = self.source.name - + unlink_method = self.plot.plotItem.unlinkDataFromAxis - + signature = inspect.signature(unlink_method) - + if len(signature.parameters) > 1: self.plot.plotItem.unlinkDataFromAxis(curve_item.source, old_axis_name) else: self.plot.plotItem.unlinkDataFromAxis(curve_item.source) - + axis = self.plot.plotItem.getAxis(old_axis_name) if axis is not None: old_view = axis.linkedView() - if old_view is not None and hasattr(old_view, 'removeItem'): + if old_view is not None and hasattr(old_view, "removeItem"): old_view.removeItem(curve_item.source) - + if self.layout().indexOf(curve_item) != -1: self.layout().removeWidget(curve_item) curve_item.setParent(None) @@ -764,21 +764,21 @@ def add_curve_item(self, curve_item: "CurveItem") -> None: if current_axis and current_axis != self.source.name: unlink_method = self.plot.plotItem.unlinkDataFromAxis signature = inspect.signature(unlink_method) - - if len(signature.parameters) > 1 and hasattr(self.plot.plotItem, 'unlinkDataFromAxis'): + + if len(signature.parameters) > 1 and hasattr(self.plot.plotItem, "unlinkDataFromAxis"): self.plot.plotItem.unlinkDataFromAxis(curve_item.source, current_axis) - if hasattr(self.plot.plotItem, 'linkDataToAxis'): + if hasattr(self.plot.plotItem, "linkDataToAxis"): self.plot.plotItem.linkDataToAxis(curve_item.source, self.source.name) - + curve_item.source.y_axis_name = self.source.name - + curve_item.curve_deleted.connect(lambda curve: self.handle_curve_deleted(curve)) curve_item.active_toggle.setCheckState(self.active_toggle.checkState()) if self.layout().indexOf(curve_item) != -1: self.layout().removeWidget(curve_item) - + idx = self.layout().indexOf(self.placeholder) self.layout().insertWidget(idx, curve_item) From df4d446761fcc82c2c6b1f0449b3ace68e121dd9 Mon Sep 17 00:00:00 2001 From: Zach Domke Date: Wed, 17 Sep 2025 11:15:49 -0700 Subject: [PATCH 3/3] FIX: Simplify error bar fix --- trace/widgets/control_panel.py | 39 ++++++---------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/trace/widgets/control_panel.py b/trace/widgets/control_panel.py index c828afa6..60d70335 100644 --- a/trace/widgets/control_panel.py +++ b/trace/widgets/control_panel.py @@ -1,5 +1,4 @@ import re -import inspect from qtpy import QtGui, QtCore, QtWidgets from qtpy.QtCore import Qt, Slot, QTimer @@ -727,26 +726,9 @@ def remove_curve_item(self, curve_item: "CurveItem", delete_curve: bool = False) from the plot entirely. If False, it will just be unlinked from this axis., by default False. """ - old_axis_name = self.source.name - - unlink_method = self.plot.plotItem.unlinkDataFromAxis - - signature = inspect.signature(unlink_method) - - if len(signature.parameters) > 1: - self.plot.plotItem.unlinkDataFromAxis(curve_item.source, old_axis_name) - else: - self.plot.plotItem.unlinkDataFromAxis(curve_item.source) - - axis = self.plot.plotItem.getAxis(old_axis_name) - if axis is not None: - old_view = axis.linkedView() - if old_view is not None and hasattr(old_view, "removeItem"): - old_view.removeItem(curve_item.source) - - if self.layout().indexOf(curve_item) != -1: - self.layout().removeWidget(curve_item) - curve_item.setParent(None) + curve_item.curve_deleted.disconnect() + self.layout().removeWidget(curve_item) + self.plot.plotItem.unlinkDataFromAxis(curve_item.source) if delete_curve: curve_item.close() @@ -760,18 +742,9 @@ def add_curve_item(self, curve_item: "CurveItem") -> None: curve_item : CurveItem The CurveItem to be added to this axis. """ - current_axis = getattr(curve_item.source, "y_axis_name", None) - if current_axis and current_axis != self.source.name: - unlink_method = self.plot.plotItem.unlinkDataFromAxis - signature = inspect.signature(unlink_method) - - if len(signature.parameters) > 1 and hasattr(self.plot.plotItem, "unlinkDataFromAxis"): - self.plot.plotItem.unlinkDataFromAxis(curve_item.source, current_axis) - - if hasattr(self.plot.plotItem, "linkDataToAxis"): - self.plot.plotItem.linkDataToAxis(curve_item.source, self.source.name) - - curve_item.source.y_axis_name = self.source.name + # Need to link curve to axis before setting y_axis_name on curve + self.plot.plotItem.linkDataToAxis(curve_item.source, self.name) + curve_item.source.y_axis_name = self.name curve_item.curve_deleted.connect(lambda curve: self.handle_curve_deleted(curve)) curve_item.active_toggle.setCheckState(self.active_toggle.checkState())