mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
feat(positioner_box): add units QLabel to device UI components and update visibility logic
This commit is contained in:
@ -40,6 +40,7 @@ class DeviceUpdateUIComponents(TypedDict):
|
|||||||
stop: QPushButton
|
stop: QPushButton
|
||||||
tweak_increase: QPushButton
|
tweak_increase: QPushButton
|
||||||
tweak_decrease: QPushButton
|
tweak_decrease: QPushButton
|
||||||
|
units: QLabel
|
||||||
|
|
||||||
|
|
||||||
class PositionerBoxBase(BECWidget, CompactPopupWidget):
|
class PositionerBoxBase(BECWidget, CompactPopupWidget):
|
||||||
@ -84,16 +85,33 @@ class PositionerBoxBase(BECWidget, CompactPopupWidget):
|
|||||||
limit_update: Callable[[tuple[float, float]], None],
|
limit_update: Callable[[tuple[float, float]], None],
|
||||||
):
|
):
|
||||||
"""Init the device view and readback"""
|
"""Init the device view and readback"""
|
||||||
if self._check_device_is_valid(device):
|
if not self._check_device_is_valid(device):
|
||||||
data = self.dev[device].read()
|
return
|
||||||
self._on_device_readback(
|
|
||||||
device,
|
data = self.dev[device].read()
|
||||||
self._device_ui_components(device),
|
self._on_device_readback(
|
||||||
{"signals": data},
|
device,
|
||||||
{},
|
self._device_ui_components(device),
|
||||||
position_emit,
|
{"signals": data},
|
||||||
limit_update,
|
{},
|
||||||
)
|
position_emit,
|
||||||
|
limit_update,
|
||||||
|
)
|
||||||
|
|
||||||
|
ui = self._device_ui_components(device)
|
||||||
|
if not ui.get("units"):
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
egu = f"[{self.dev[device].egu()}]"
|
||||||
|
except Exception:
|
||||||
|
egu = ""
|
||||||
|
|
||||||
|
if egu:
|
||||||
|
ui["units"].setVisible(True)
|
||||||
|
ui["units"].setText(egu)
|
||||||
|
else:
|
||||||
|
ui["units"].setVisible(False)
|
||||||
|
|
||||||
def _stop_device(self, device: str):
|
def _stop_device(self, device: str):
|
||||||
"""Stop call"""
|
"""Stop call"""
|
||||||
|
@ -170,6 +170,7 @@ class PositionerBox(PositionerBoxBase):
|
|||||||
"stop": self.ui.stop,
|
"stop": self.ui.stop,
|
||||||
"tweak_increase": self.ui.tweak_right,
|
"tweak_increase": self.ui.tweak_right,
|
||||||
"tweak_decrease": self.ui.tweak_left,
|
"tweak_decrease": self.ui.tweak_left,
|
||||||
|
"units": self.ui.units,
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeSlot(dict, dict)
|
@SafeSlot(dict, dict)
|
||||||
|
@ -135,6 +135,29 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="units">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Motor units</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -203,16 +226,16 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>SpinnerWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>spinner_widget</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>PositionIndicator</class>
|
<class>PositionIndicator</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>position_indicator</header>
|
<header>position_indicator</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>SpinnerWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>spinner_widget</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
""" Module for a PositionerBox2D widget to control two positioner devices."""
|
"""Module for a PositionerBox2D widget to control two positioner devices."""
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@ -312,6 +312,7 @@ class PositionerBox2D(PositionerBoxBase):
|
|||||||
"stop": self.ui.stop_button,
|
"stop": self.ui.stop_button,
|
||||||
"tweak_increase": self.ui.tweak_increase_hor,
|
"tweak_increase": self.ui.tweak_increase_hor,
|
||||||
"tweak_decrease": self.ui.tweak_decrease_hor,
|
"tweak_decrease": self.ui.tweak_decrease_hor,
|
||||||
|
"units": self.ui.units_hor,
|
||||||
}
|
}
|
||||||
elif device == "vertical":
|
elif device == "vertical":
|
||||||
return {
|
return {
|
||||||
@ -324,6 +325,7 @@ class PositionerBox2D(PositionerBoxBase):
|
|||||||
"stop": self.ui.stop_button,
|
"stop": self.ui.stop_button,
|
||||||
"tweak_increase": self.ui.tweak_increase_ver,
|
"tweak_increase": self.ui.tweak_increase_ver,
|
||||||
"tweak_decrease": self.ui.tweak_decrease_ver,
|
"tweak_decrease": self.ui.tweak_decrease_ver,
|
||||||
|
"units": self.ui.units_ver,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Device {device} is not represented by this UI")
|
raise ValueError(f"Device {device} is not represented by this UI")
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>326</width>
|
<width>402</width>
|
||||||
<height>323</height>
|
<height>394</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>No positioner selected</string>
|
<string>No positioner selected</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_6" rowstretch="0,0,0,0,0,0">
|
<layout class="QGridLayout" name="gridLayout_6" rowstretch="0,0,0,0,0,0,0">
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@ -40,15 +40,38 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="readback_ver">
|
<spacer name="horizontalSpacer_18">
|
||||||
<property name="text">
|
<property name="orientation">
|
||||||
<string>Position</string>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="sizeHint" stdset="0">
|
||||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="units_ver">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_19">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="SpinnerWidget" name="spinner_widget_ver">
|
<widget class="SpinnerWidget" name="spinner_widget_ver">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -67,20 +90,7 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLineEdit" name="setpoint_ver">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="focusPolicy">
|
|
||||||
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDoubleSpinBox" name="step_size_ver">
|
<widget class="QDoubleSpinBox" name="step_size_ver">
|
||||||
@ -94,6 +104,29 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLineEdit" name="setpoint_ver">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::FocusPolicy::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="readback_ver">
|
||||||
|
<property name="text">
|
||||||
|
<string>Position</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -132,15 +165,38 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="readback_hor">
|
<spacer name="horizontalSpacer_9">
|
||||||
<property name="text">
|
<property name="orientation">
|
||||||
<string>Position</string>
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="sizeHint" stdset="0">
|
||||||
<set>Qt::AlignmentFlag::AlignCenter</set>
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="units_hor">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_13">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="SpinnerWidget" name="spinner_widget_hor">
|
<widget class="SpinnerWidget" name="spinner_widget_hor">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -173,6 +229,16 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="readback_hor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Position</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignmentFlag::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -525,16 +591,16 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>StopButton</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>stop_button</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>PositionIndicator</class>
|
<class>PositionIndicator</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>position_indicator</header>
|
<header>position_indicator</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>StopButton</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>stop_button</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>SpinnerWidget</class>
|
<class>SpinnerWidget</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
|
@ -116,6 +116,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="units">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -218,16 +225,16 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>SpinnerWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>spinner_widget</header>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>PositionIndicator</class>
|
<class>PositionIndicator</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>position_indicator</header>
|
<header>position_indicator</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>SpinnerWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>spinner_widget</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
Reference in New Issue
Block a user