mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-12-30 10:41:18 +01:00
fix(curve): fix unique names for custom curves
This commit is contained in:
@@ -93,7 +93,7 @@ class Curve(BECConnector, pg.PlotDataItem):
|
||||
self.config = config
|
||||
self.parent_item = parent_item
|
||||
self.parent_id = self.parent_item.gui_id
|
||||
object_name = name.replace("-", "_") if name else None
|
||||
object_name = name.replace("-", "_").replace(" ", "_") if name else None
|
||||
super().__init__(name=name, object_name=object_name, config=config, gui_id=gui_id, **kwargs)
|
||||
|
||||
self.apply_config()
|
||||
|
||||
@@ -15,6 +15,7 @@ from qtpy.QtWidgets import QApplication, QDialog, QHBoxLayout, QMainWindow, QVBo
|
||||
from bec_widgets.utils import ConnectionConfig
|
||||
from bec_widgets.utils.bec_signal_proxy import BECSignalProxy
|
||||
from bec_widgets.utils.colors import Colors, set_theme
|
||||
from bec_widgets.utils.container_utils import WidgetContainerUtils
|
||||
from bec_widgets.utils.error_popups import SafeProperty, SafeSlot
|
||||
from bec_widgets.utils.settings_dialog import SettingsDialog
|
||||
from bec_widgets.utils.toolbar import MaterialIconAction
|
||||
@@ -644,7 +645,9 @@ class Waveform(PlotBase):
|
||||
# Decide label if not provided
|
||||
if label is None:
|
||||
if source == "custom":
|
||||
label = f"Curve {len(self.curves) + 1}"
|
||||
label = WidgetContainerUtils.generate_unique_name(
|
||||
"Curve", [c.object_name for c in self.curves]
|
||||
)
|
||||
else:
|
||||
label = f"{y_name}-{y_entry}"
|
||||
|
||||
@@ -769,7 +772,9 @@ class Waveform(PlotBase):
|
||||
label = config.label
|
||||
if not label:
|
||||
# Fallback label
|
||||
label = f"Curve {len(self.curves) + 1}"
|
||||
label = WidgetContainerUtils.generate_unique_name(
|
||||
"Curve", [c.object_name for c in self.curves]
|
||||
)
|
||||
config.label = label
|
||||
|
||||
# Check for duplicates
|
||||
|
||||
Reference in New Issue
Block a user