Positioner Box 2D Widget#
The PositionerBox2D widget is very similar to the PositionerBox but allows controlling two positioners at the same time, in a horizontal and vertical orientation respectively. It is intended primarily for controlling axes which have a perpendicular relationship like that. In other cases, it may be better to use a PositionerGroup instead.
The PositionerBox2D has the same features as the standard PositionerBox, but additionally, step buttons which move the positioner by the selected step size, and tweak buttons which move by a tenth of the selected step size.
The PositionerBox2D widget can be integrated within a GUI application either through direct code instantiation or by using BEC Designer. Below are examples demonstrating how to create and use the PositionerBox2D widget.
Example 1 - Creating a PositionerBox in Code
In this example, we demonstrate how to create a PositionerBox2D widget in code and configure it for a specific device.
from qtpy.QtWidgets import QApplication, QVBoxLayout, QWidget
from bec_widgets.widgets.positioner_box import PositionerBox2D
class MyGui(QWidget):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setLayout(QVBoxLayout(self)) # Initialize the layout for the widget
# Create and add the PositionerBox to the layout
self.positioner_box_2d = PositionerBox(parent=self, device_hor="horizontal_motor", device_ver="vertical_motor")
self.layout().addWidget(self.positioner_box_2d)
# Example of how this custom GUI might be used:
app = QApplication([])
my_gui = MyGui()
my_gui.show()
app.exec_()
Example 2 - Selecting a Device via GUI
Users can select the positioner device by clicking the button under the device label, which opens a dialog for device selection.
Example 3 - Customizing PositionerBox in BEC Designer
The PositionerBox2D widget can be added to a GUI through BEC Designer. Once integrated, you can configure the default device and customize the widget’s appearance and behavior directly within the designer.
# After adding the widget to a form in BEC Designer, you can configure the device:
self.positioner_box.set_positioner_hor("samx")
self.positioner_box.set_positioner_verr("samy")
- class PositionerBox2D(gui_id: str | None = None, config: dict | None = None, object_name: str | None = None, parent=None, **kwargs)[source]#
Bases:
RPCBaseSimple Widget to control two positioners in box form
- detach()[source]#
Detach the widget from its parent dock widget (if widget is in the dock), making it a floating widget.
- property enable_controls_hor: bool#
Persisted switch for horizontal control buttons (tweak/step).
- property enable_controls_ver: bool#
Persisted switch for vertical control buttons (tweak/step).
- screenshot(file_name: str | None = None)[source]#
Take a screenshot of the dock area and save it to a file.
- set_positioner_hor(positioner: str | Positioner)[source]#
Set the device
- Parameters:
positioner (Positioner | str) – Positioner to set, accepts str or the device
- set_positioner_ver(positioner: str | Positioner)[source]#
Set the device
- Parameters:
positioner (Positioner | str) – Positioner to set, accepts str or the device