From a614acec4f9dbd20f3d801061198faee28d097a5 Mon Sep 17 00:00:00 2001 From: wyzula-jan <133381102+wyzula-jan@users.noreply.github.com> Date: Tue, 19 Mar 2024 11:02:32 +0100 Subject: [PATCH] fix(widgets/motor_controls): hotfix to create default config structure to avoid type None errors; cursor button size increased --- .../widgets/motor_control/motor_control.py | 2 ++ .../motor_control/motor_control_relative.ui | 16 ++++++------- bec_widgets/widgets/motor_map/motor_map.py | 24 ++++++++++++------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/bec_widgets/widgets/motor_control/motor_control.py b/bec_widgets/widgets/motor_control/motor_control.py index ceab7734..955fc2b8 100644 --- a/bec_widgets/widgets/motor_control/motor_control.py +++ b/bec_widgets/widgets/motor_control/motor_control.py @@ -1,5 +1,6 @@ # pylint: disable = no-name-in-module,missing-module-docstring import os +from collections import defaultdict from enum import Enum from qtpy import uic @@ -59,6 +60,7 @@ class MotorControlWidget(QWidget): if self.config is None: print(f"No initial config found for {self.__class__.__name__}") + self.config = defaultdict(dict) self._init_ui() else: self.on_config_update(self.config) diff --git a/bec_widgets/widgets/motor_control/motor_control_relative.ui b/bec_widgets/widgets/motor_control/motor_control_relative.ui index 78fed89b..9f81d715 100644 --- a/bec_widgets/widgets/motor_control/motor_control_relative.ui +++ b/bec_widgets/widgets/motor_control/motor_control_relative.ui @@ -167,8 +167,8 @@ - 26 - 26 + 50 + 50 @@ -196,8 +196,8 @@ - 26 - 26 + 50 + 50 @@ -212,8 +212,8 @@ - 26 - 26 + 50 + 50 @@ -241,8 +241,8 @@ - 26 - 26 + 50 + 50 diff --git a/bec_widgets/widgets/motor_map/motor_map.py b/bec_widgets/widgets/motor_map/motor_map.py index ff82bf47..74c5d358 100644 --- a/bec_widgets/widgets/motor_map/motor_map.py +++ b/bec_widgets/widgets/motor_map/motor_map.py @@ -2,6 +2,7 @@ from __future__ import annotations import time +from collections import defaultdict from typing import Any, Union import numpy as np @@ -36,15 +37,6 @@ CONFIG_DEFAULT = { "y": [{"name": "samy", "entry": "samy"}], }, }, - { - "plot_name": "Motor Map 2 ", - "x_label": "Motor X", - "y_label": "Motor Y", - "signals": { - "x": [{"name": "aptrx", "entry": "aptrx"}], - "y": [{"name": "aptry", "entry": "aptry"}], - }, - }, ], } @@ -99,6 +91,7 @@ class MotorMap(pg.GraphicsLayoutWidget): # Init UI with config if self.config is None: print("No initial config found for MotorMap. Using default config.") + self.config = CONFIG_DEFAULT # defaultdict(dict) else: self.on_config_update(self.config) @@ -131,6 +124,19 @@ class MotorMap(pg.GraphicsLayoutWidget): motor_y(str): Motor name for the Y axis. subplot(int): Subplot number. """ + if self.plot_data is None: + self.plot_data = ( + { + "plot_name": "Motor Map", + "x_label": "Motor X", + "y_label": "Motor Y", + "signals": { + "x": [{"name": motor_x, "entry": motor_x}], + "y": [{"name": motor_y, "entry": motor_y}], + }, + }, + ) + if subplot >= len(self.plot_data): print(f"Invalid subplot index: {subplot}. Available subplots: {len(self.plot_data)}") return