diff --git a/bec_widgets/examples/__init__.py b/bec_widgets/examples/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/bec_widgets/examples/motor_movement/motor_controller.ui b/bec_widgets/examples/motor_movement/motor_controller.ui new file mode 100644 index 00000000..ebb64c7b --- /dev/null +++ b/bec_widgets/examples/motor_movement/motor_controller.ui @@ -0,0 +1,160 @@ + + + Form + + + + 0 + 0 + 800 + 266 + + + + Motor Controller + + + + + + false + + + Motor Limits + + + + + + + samy + + + + + + + + + + Update + + + + + + + + + + - samy + + + + + + + + + + + + + - samx + + + + + + + - samx + + + + + + + + + + false + + + + + + + Motor Controls + + + + + + 5 + + + + + + + ... + + + Qt::LeftArrow + + + + + + + ... + + + Qt::UpArrow + + + + + + + ... + + + Qt::DownArrow + + + + + + + ... + + + Qt::RightArrow + + + + + + + + + + Motor Status + + + Qt::AlignCenter + + + + + + + + GraphicsLayoutWidget + QGraphicsView +
pyqtgraph.h
+
+
+ + +
diff --git a/bec_widgets/examples/motor_movement/motor_example.py b/bec_widgets/examples/motor_movement/motor_example.py new file mode 100644 index 00000000..2c0d5106 --- /dev/null +++ b/bec_widgets/examples/motor_movement/motor_example.py @@ -0,0 +1,68 @@ +import os + +from PyQt5.QtCore import pyqtSignal +from PyQt5.QtWidgets import QApplication, QWidget +from pyqtgraph.Qt import QtCore, QtWidgets, uic +import pyqtgraph as pg + + +class MotorApp(QWidget): + motor_position = pyqtSignal(float) # TODO hook to motor position update + + def __init__(self): + super().__init__() + current_path = os.path.dirname(__file__) + uic.loadUi(os.path.join(current_path, "motor_controller.ui"), self) + + # UI + + self.init_ui() + + def init_ui(self): + """Setup all ui elements""" + ########################## + # 2D Plot + ########################## + + self.label_coorditanes = self.glw.addLabel("Current Motor Coordinates", row=0, col=0) + self.plot_map = self.glw.addPlot(row=1, col=0) + self.image_map = pg.ImageItem() + self.plot_map.addItem(self.image_map) + + ########################## + # Signals + ########################## + # Buttons - Motor Movement + self.toolButton_right.clicked.connect( + lambda: self.move_motor(dev.samx, self.spinBox_step.value()) + ) + self.toolButton_left.clicked.connect( + lambda: self.move_motor(dev.samx, -self.spinBox_step.value()) + ) + self.toolButton_up.clicked.connect( + lambda: self.move_motor(dev.samy, self.spinBox_step.value()) + ) + self.toolButton_down.clicked.connect( + lambda: self.move_motor(dev.samy, -self.spinBox_step.value()) + ) + + # self.toolButton_left.clicked.connect(lambda: print(self.client)) + + def move_motor(self, motor, value: float) -> None: + scans.mv(motor, value, relative=True) + self.motor_position.emit(motor.position) + + +if __name__ == "__main__": + from bec_widgets.bec_dispatcher import bec_dispatcher + + # Client initialization + client = bec_dispatcher.client + client.start() + dev = client.device_manager.devices + scans = client.scans + + app = QApplication([]) + window = MotorApp() + window.show() + app.exec_() diff --git a/bec_widgets/examples/crosshair_example.py b/bec_widgets/examples/plotting/crosshair_example.py similarity index 99% rename from bec_widgets/examples/crosshair_example.py rename to bec_widgets/examples/plotting/crosshair_example.py index f15ed110..5aed65aa 100644 --- a/bec_widgets/examples/crosshair_example.py +++ b/bec_widgets/examples/plotting/crosshair_example.py @@ -12,7 +12,8 @@ from PyQt5.QtWidgets import ( ) from pyqtgraph import mkPen from pyqtgraph.Qt import QtCore -from crosshair import Crosshair +from bec_widgets.qt_utils import Crosshair + class ExampleApp(QWidget):