mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-03-04 16:02:51 +01:00
fix(widgets/motor_controls): hotfix to create default config structure to avoid type None errors; cursor button size increased
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -167,8 +167,8 @@
|
||||
<widget class="QToolButton" name="toolButton_up">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>26</width>
|
||||
<height>26</height>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -196,8 +196,8 @@
|
||||
<widget class="QToolButton" name="toolButton_down">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>26</width>
|
||||
<height>26</height>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -212,8 +212,8 @@
|
||||
<widget class="QToolButton" name="toolButton_left">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>26</width>
|
||||
<height>26</height>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
@@ -241,8 +241,8 @@
|
||||
<widget class="QToolButton" name="toolButton_right">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>26</width>
|
||||
<height>26</height>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user