From 8d363e58d6b624eb9ef9c11b4c6f58f56d727608 Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Tue, 9 Jul 2024 18:02:38 +0200 Subject: [PATCH] wip --- .../widgets/bec_queue/bec_queue_plugin.py | 2 +- .../bec_status_box/bec_status_box_plugin.py | 2 +- bec_widgets/widgets/device_box/device_box.py | 10 +- .../widgets/device_box/device_control_line.py | 22 +++ .../widgets/device_box/device_control_line.ui | 181 ++++++++++++++++++ 5 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 bec_widgets/widgets/device_box/device_control_line.py create mode 100644 bec_widgets/widgets/device_box/device_control_line.ui diff --git a/bec_widgets/widgets/bec_queue/bec_queue_plugin.py b/bec_widgets/widgets/bec_queue/bec_queue_plugin.py index 8dcd6d9b..f0decf45 100644 --- a/bec_widgets/widgets/bec_queue/bec_queue_plugin.py +++ b/bec_widgets/widgets/bec_queue/bec_queue_plugin.py @@ -27,7 +27,7 @@ class BECQueuePlugin(QDesignerCustomWidgetInterface): # pragma: no cover return DOM_XML def group(self): - return "" + return "BEC Core Widgets" def icon(self): return QIcon() diff --git a/bec_widgets/widgets/bec_status_box/bec_status_box_plugin.py b/bec_widgets/widgets/bec_status_box/bec_status_box_plugin.py index 97690dc2..1038353f 100644 --- a/bec_widgets/widgets/bec_status_box/bec_status_box_plugin.py +++ b/bec_widgets/widgets/bec_status_box/bec_status_box_plugin.py @@ -27,7 +27,7 @@ class BECStatusBoxPlugin(QDesignerCustomWidgetInterface): # pragma: no cover return DOM_XML def group(self): - return "" + return "BEC Core Widgets" def icon(self): return QIcon() diff --git a/bec_widgets/widgets/device_box/device_box.py b/bec_widgets/widgets/device_box/device_box.py index edd758a8..5b3cfaa7 100644 --- a/bec_widgets/widgets/device_box/device_box.py +++ b/bec_widgets/widgets/device_box/device_box.py @@ -12,6 +12,10 @@ from bec_widgets.utils.bec_connector import BECConnector class DeviceBox(BECConnector, QWidget): + """A widget that controls a single device.""" + + ui_file = "device_box.ui" + dimensions = (234, 224) device_changed = Signal(str, str) def __init__(self, parent=None, device=None, *args, **kwargs): @@ -31,7 +35,7 @@ class DeviceBox(BECConnector, QWidget): self.device_changed.connect(self.on_device_change) current_path = os.path.dirname(__file__) - self.ui = UILoader(self).loader(os.path.join(current_path, "device_box.ui")) + self.ui = UILoader(self).loader(os.path.join(current_path, self.ui_file)) self.layout = QVBoxLayout(self) self.layout.addWidget(self.ui) @@ -40,8 +44,8 @@ class DeviceBox(BECConnector, QWidget): # fix the size of the device box db = self.ui.device_box - db.setFixedHeight(234) - db.setFixedWidth(224) + db.setFixedHeight(self.dimensions[0]) + db.setFixedWidth(self.dimensions[1]) self.ui.step_size.setStepType(QDoubleSpinBox.AdaptiveDecimalStepType) self.ui.stop.clicked.connect(self.on_stop) diff --git a/bec_widgets/widgets/device_box/device_control_line.py b/bec_widgets/widgets/device_box/device_control_line.py new file mode 100644 index 00000000..457a9ba2 --- /dev/null +++ b/bec_widgets/widgets/device_box/device_control_line.py @@ -0,0 +1,22 @@ +from bec_widgets.widgets.device_box.device_box import DeviceBox + + +class DeviceControlLine(DeviceBox): + """A widget that controls a single device.""" + + ui_file = "device_control_line.ui" + dimensions = (70, 800) # height, width + + +if __name__ == "__main__": # pragma: no cover + import sys + + import qdarktheme + from qtpy.QtWidgets import QApplication + + app = QApplication(sys.argv) + qdarktheme.setup_theme("light") + widget = DeviceControlLine(device="samy") + + widget.show() + sys.exit(app.exec_()) diff --git a/bec_widgets/widgets/device_box/device_control_line.ui b/bec_widgets/widgets/device_box/device_control_line.ui new file mode 100644 index 00000000..2f652087 --- /dev/null +++ b/bec_widgets/widgets/device_box/device_control_line.ui @@ -0,0 +1,181 @@ + + + Form + + + + 0 + 0 + 785 + 91 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Form + + + + + + Device Name + + + + + + + + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + Position + + + Qt::AlignmentFlag::AlignCenter + + + + + + + + 150 + 24 + + + + + 150 + 16777215 + + + + + + + + + + Stop + + + + + + + + 30 + 30 + + + + + 30 + 30 + + + + ... + + + + 30 + 30 + + + + Qt::ArrowType::LeftArrow + + + + + + + + + + + 30 + 30 + + + + + 30 + 30 + + + + ... + + + + 30 + 30 + + + + Qt::ArrowType::RightArrow + + + + + + + + 25 + 25 + + + + + 25 + 25 + + + + + + + + + + + + SpinnerWidget + QWidget +
spinner_widget
+
+ + PositionIndicator + QWidget +
position_indicator
+
+
+ + +