bec-widgets 0.99.8__py3-none-any.whl → 0.99.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CHANGELOG.md +18 -20
- PKG-INFO +1 -1
- bec_widgets/widgets/positioner_box/positioner_box.py +23 -11
- bec_widgets/widgets/stop_button/stop_button.py +30 -13
- {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.10.dist-info}/METADATA +1 -1
- {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.10.dist-info}/RECORD +10 -157
- pyproject.toml +6 -1
- docs/Makefile +0 -20
- docs/_static/custom.css +0 -170
- docs/_templates/custom-class-template.rst +0 -34
- docs/_templates/custom-module-template.rst +0 -66
- docs/api_reference/api_reference.md +0 -12
- docs/assets/apps_48dp.svg +0 -1
- docs/assets/display_settings_48dp.svg +0 -1
- docs/assets/index_api.svg +0 -97
- docs/assets/index_contribute.svg +0 -76
- docs/assets/index_getting_started.svg +0 -66
- docs/assets/index_user_guide.svg +0 -67
- docs/assets/rocket_launch_48dp.svg +0 -1
- docs/assets/widget_screenshots/buttons.png +0 -0
- docs/assets/widget_screenshots/device_box.png +0 -0
- docs/assets/widget_screenshots/device_browser.png +0 -0
- docs/assets/widget_screenshots/device_inputs.png +0 -0
- docs/assets/widget_screenshots/dock_area.png +0 -0
- docs/assets/widget_screenshots/figure.png +0 -0
- docs/assets/widget_screenshots/image_widget.png +0 -0
- docs/assets/widget_screenshots/motor_map_widget.png +0 -0
- docs/assets/widget_screenshots/position_indicator.png +0 -0
- docs/assets/widget_screenshots/queue.png +0 -0
- docs/assets/widget_screenshots/ring_progress_bar.png +0 -0
- docs/assets/widget_screenshots/scan_controller.png +0 -0
- docs/assets/widget_screenshots/spinner.gif +0 -0
- docs/assets/widget_screenshots/status_box.png +0 -0
- docs/assets/widget_screenshots/text_box.png +0 -0
- docs/assets/widget_screenshots/toggle.png +0 -0
- docs/assets/widget_screenshots/waveform_widget.png +0 -0
- docs/assets/widget_screenshots/website.png +0 -0
- docs/conf.py +0 -82
- docs/developer/developer.md +0 -52
- docs/developer/introduction/concepts.md +0 -14
- docs/developer/introduction/contributing.md +0 -28
- docs/developer/introduction/introduction.md +0 -16
- docs/developer/introduction/useful_links.md +0 -23
- docs/developer/widget_development/bec_dispatcher.md +0 -143
- docs/developer/widget_development/widget_base_class.md +0 -171
- docs/developer/widget_development/widget_development.md +0 -14
- docs/index.md +0 -74
- docs/introduction/introduction.md +0 -18
- docs/make.bat +0 -35
- docs/requirements.txt +0 -12
- docs/user/api_reference/api_reference.md +0 -11
- docs/user/applications/applications.md +0 -10
- docs/user/customisation.md +0 -123
- docs/user/getting_started/BECDockArea.png +0 -0
- docs/user/getting_started/auto_updates.md +0 -82
- docs/user/getting_started/getting_started.md +0 -15
- docs/user/getting_started/gui_complex_gui.gif +0 -0
- docs/user/getting_started/installation.md +0 -33
- docs/user/getting_started/quick_start.md +0 -110
- docs/user/getting_started/video_tutorials.md +0 -17
- docs/user/user.md +0 -71
- docs/user/widgets/bec_figure/BECFigure.png +0 -0
- docs/user/widgets/bec_figure/bec_figure.md +0 -105
- docs/user/widgets/bec_status_box/bec_status_box.gif +0 -0
- docs/user/widgets/bec_status_box/bec_status_box.md +0 -38
- docs/user/widgets/buttons/buttons.md +0 -90
- docs/user/widgets/buttons/dark_mode_disabled.png +0 -0
- docs/user/widgets/buttons/dark_mode_enabled.png +0 -0
- docs/user/widgets/device_browser/device_browser.md +0 -36
- docs/user/widgets/device_browser/device_browser.png +0 -0
- docs/user/widgets/device_input/device_input.md +0 -100
- docs/user/widgets/dock_area/BECDockArea.png +0 -0
- docs/user/widgets/dock_area/bec_dock_area.md +0 -109
- docs/user/widgets/image/image_plot.gif +0 -0
- docs/user/widgets/image/image_widget.md +0 -84
- docs/user/widgets/motor_map/motor.gif +0 -0
- docs/user/widgets/motor_map/motor_map.md +0 -80
- docs/user/widgets/position_indicator/position_indicator.md +0 -69
- docs/user/widgets/positioner_box/positioner_box.md +0 -63
- docs/user/widgets/progress_bar/progress_bar.gif +0 -0
- docs/user/widgets/progress_bar/ring_progress_bar.md +0 -103
- docs/user/widgets/queue/queue.md +0 -41
- docs/user/widgets/scan_control/hide_scan_control.png +0 -0
- docs/user/widgets/scan_control/scan_control.gif +0 -0
- docs/user/widgets/scan_control/scan_control.md +0 -54
- docs/user/widgets/spinner/spinner.md +0 -68
- docs/user/widgets/text_box/text_box.md +0 -74
- docs/user/widgets/toggle/toggle.md +0 -66
- docs/user/widgets/waveform/bec_figure_dap.gif +0 -0
- docs/user/widgets/waveform/scatter_2D.gif +0 -0
- docs/user/widgets/waveform/w1D.gif +0 -0
- docs/user/widgets/waveform/waveform_widget.md +0 -132
- docs/user/widgets/website/website.md +0 -69
- docs/user/widgets/widgets.md +0 -220
- tests/__init__.py +0 -0
- tests/end-2-end/__init__.py +0 -0
- tests/end-2-end/conftest.py +0 -53
- tests/end-2-end/test_bec_dock_rpc_e2e.py +0 -298
- tests/end-2-end/test_bec_figure_rpc_e2e.py +0 -212
- tests/end-2-end/test_rpc_register_e2e.py +0 -40
- tests/end-2-end/test_scan_control_e2e.py +0 -71
- tests/references/SpinnerWidget/SpinnerWidget_darwin.png +0 -0
- tests/references/SpinnerWidget/SpinnerWidget_linux.png +0 -0
- tests/references/SpinnerWidget/SpinnerWidget_started_darwin.png +0 -0
- tests/references/SpinnerWidget/SpinnerWidget_started_linux.png +0 -0
- tests/unit_tests/__init__.py +0 -0
- tests/unit_tests/client_mocks.py +0 -189
- tests/unit_tests/conftest.py +0 -64
- tests/unit_tests/test_bec_connector.py +0 -80
- tests/unit_tests/test_bec_dispatcher.py +0 -119
- tests/unit_tests/test_bec_dock.py +0 -155
- tests/unit_tests/test_bec_figure.py +0 -270
- tests/unit_tests/test_bec_image.py +0 -63
- tests/unit_tests/test_bec_image_widget.py +0 -217
- tests/unit_tests/test_bec_motor_map.py +0 -282
- tests/unit_tests/test_bec_queue.py +0 -111
- tests/unit_tests/test_bec_status_box.py +0 -123
- tests/unit_tests/test_client_utils.py +0 -76
- tests/unit_tests/test_color_map_selector.py +0 -42
- tests/unit_tests/test_color_validation.py +0 -75
- tests/unit_tests/test_configs/config_device.yaml +0 -33
- tests/unit_tests/test_configs/config_device_no_entry.yaml +0 -27
- tests/unit_tests/test_configs/config_scan.yaml +0 -82
- tests/unit_tests/test_crosshair.py +0 -143
- tests/unit_tests/test_dark_mode_button.py +0 -70
- tests/unit_tests/test_device_browser.py +0 -83
- tests/unit_tests/test_device_input_base.py +0 -76
- tests/unit_tests/test_device_input_widgets.py +0 -178
- tests/unit_tests/test_error_utils.py +0 -63
- tests/unit_tests/test_generate_cli_client.py +0 -123
- tests/unit_tests/test_generate_plugin.py +0 -155
- tests/unit_tests/test_motor_map_widget.py +0 -194
- tests/unit_tests/test_msgs/__init__.py +0 -0
- tests/unit_tests/test_msgs/available_scans_message.py +0 -989
- tests/unit_tests/test_plot_base.py +0 -95
- tests/unit_tests/test_plugin_utils.py +0 -13
- tests/unit_tests/test_positioner_box.py +0 -130
- tests/unit_tests/test_ring_progress_bar.py +0 -337
- tests/unit_tests/test_rpc_register.py +0 -52
- tests/unit_tests/test_rpc_server.py +0 -42
- tests/unit_tests/test_rpc_widget_handler.py +0 -7
- tests/unit_tests/test_scan_control.py +0 -324
- tests/unit_tests/test_scan_control_group_box.py +0 -160
- tests/unit_tests/test_setting_dialog.py +0 -96
- tests/unit_tests/test_spinner.py +0 -31
- tests/unit_tests/test_stop_button.py +0 -27
- tests/unit_tests/test_text_box_widget.py +0 -54
- tests/unit_tests/test_toggle.py +0 -38
- tests/unit_tests/test_vscode_widget.py +0 -75
- tests/unit_tests/test_waveform1d.py +0 -712
- tests/unit_tests/test_waveform_widget.py +0 -462
- tests/unit_tests/test_website_widget.py +0 -25
- tests/unit_tests/test_widget_io.py +0 -90
- tests/unit_tests/test_yaml_dialog.py +0 -163
- {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.10.dist-info}/WHEEL +0 -0
- {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.10.dist-info}/entry_points.txt +0 -0
- {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.10.dist-info}/licenses/LICENSE +0 -0
@@ -1,28 +0,0 @@
|
|
1
|
-
(developer.contributing)=
|
2
|
-
# Contributing
|
3
|
-
|
4
|
-
If you like to contribute to the development of BEC Widgets, you can follow the steps below to set up your development environment.
|
5
|
-
BEC Widgets works in conjunction with [BEC](https://bec.readthedocs.io/en/latest/).
|
6
|
-
Therefore, we recommend that you install BEC first following the [developer instructions](https://bec.readthedocs.io/en/latest/developer/getting_started/install_developer_env.html) and include BEC Widgets.
|
7
|
-
|
8
|
-
If you already have a BEC environment set up, you can install BEC Widgets in editable mode into your BEC Python environment.
|
9
|
-
|
10
|
-
**Prerequisites**
|
11
|
-
1. **Python Version:** BEC Widgets requires Python version 3.10 or higher. Verify your Python version to ensure compatibility.
|
12
|
-
2. **BEC Installation:** BEC Widgets works in conjunction with BEC. While BEC is a dependency and will be installed automatically, you can find more information about BEC and its installation process in the [BEC documentation](https://beamline-experiment-control.readthedocs.io/en/latest/).
|
13
|
-
3. **Qt Distributions:** BEC Widgets supports [PySide6](https://doc.qt.io/qtforpython-6/quickstart.html) and [PyQt6](https://www.riverbankcomputing.com/static/Docs/PyQt6/introduction.html). We use [qtpy](https://pypi.org/project/QtPy/) to abstract the underlying QT distribution.
|
14
|
-
|
15
|
-
**Clone the Repository**:
|
16
|
-
```bash
|
17
|
-
git clone https://gitlab.psi.ch/bec/bec_widgets
|
18
|
-
cd bec_widgets
|
19
|
-
```
|
20
|
-
**Install in Editable Mode**:
|
21
|
-
|
22
|
-
Please install the package in editable mode into your BEC Python environemnt.
|
23
|
-
```bash
|
24
|
-
pip install -e '.[dev,pyside6]'
|
25
|
-
```
|
26
|
-
This installs the package together with [PySide6](https://doc.qt.io/qtforpython-6/quickstart.html).
|
27
|
-
|
28
|
-
|
@@ -1,16 +0,0 @@
|
|
1
|
-
(developer.introduction)=
|
2
|
-
# Introduction
|
3
|
-
BEC Widgets is a framework providing modular components that can be integrated into various larger GUI applications. Each widget serves a specific purpose adhering to the single-responsibility principle as detailed in our [concepts section](developer.concepts), and offers a straightforward, user-friendly interface.
|
4
|
-
These widgets provide data visualisation tools and experimental control interfaces by triggering actions within BEC.
|
5
|
-
If you're interested in contributing to BEC Widgets, please refer to our [contributing guide](developer.contributing), which provides instructions for setting up your development environment and creating your own widgets.
|
6
|
-
|
7
|
-
```{toctree}
|
8
|
-
---
|
9
|
-
maxdepth: 2
|
10
|
-
hidden: false
|
11
|
-
---
|
12
|
-
|
13
|
-
concepts/
|
14
|
-
contributing/
|
15
|
-
useful_links/
|
16
|
-
```
|
@@ -1,23 +0,0 @@
|
|
1
|
-
(developer.useful_links)=
|
2
|
-
|
3
|
-
# Useful Links
|
4
|
-
|
5
|
-
If you're new to the Qt framework, here are some helpful resources to get you started. In BEC Widgets, we use Qt
|
6
|
-
distributions based on Qt6, specifically PyQt6 and PySide6. However, all code should be written using
|
7
|
-
the [`qtpy`](https://pypi.org/project/QtPy/) abstraction layer, which allows compatibility with both. While both PyQt6
|
8
|
-
and PySide6 are supported, we prefer PySide6 as it is the official Python binding from the Qt Company. It offers
|
9
|
-
advantages like bundling all necessary libraries in a single package with pip installation and staying more up-to-date
|
10
|
-
compared to PyQt6.
|
11
|
-
|
12
|
-
Below is a list of useful links to help you start developing with Qt and QtDesigner:
|
13
|
-
|
14
|
-
- [Python GUIs](https://www.pythonguis.com): A great resource with tutorials and examples for creating GUIs in Python
|
15
|
-
using various frameworks.
|
16
|
-
- [PySide6 Quick Start Guide](https://doc.qt.io/qtforpython-6/index.html): The official documentation for PySide6,
|
17
|
-
including quick start guides and tutorials.
|
18
|
-
- [QtDesigner Official Documentation](https://doc.qt.io/qt-6/qtdesigner-manual.html): Comprehensive documentation for
|
19
|
-
QtDesigner.
|
20
|
-
- [Simple PyQt Tutorial from RealPython](https://realpython.com/python-pyqt-gui-calculator/): A beginner-friendly
|
21
|
-
tutorial on creating your first GUI application with PyQt.
|
22
|
-
- [PyQtGraph Documentation](https://pyqtgraph.readthedocs.io/en/latest/): BEC Widgets relies on PyQtGraph for plotting;
|
23
|
-
this is the official documentation.
|
@@ -1,143 +0,0 @@
|
|
1
|
-
(developer.widget_development.bec_dispatcher)=
|
2
|
-
|
3
|
-
# BECDispatcher
|
4
|
-
|
5
|
-
## Overview
|
6
|
-
|
7
|
-
The [`BECDispatcher`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher)
|
8
|
-
is a powerful tool that
|
9
|
-
simplifies the process of connecting Qt slots to message updates from the BEC server. It enables real-time communication
|
10
|
-
between your widget and the BEC server by listening to specific message channels and triggering callbacks when new data
|
11
|
-
is received.
|
12
|
-
|
13
|
-
This tool is especially useful for creating widgets that need to respond to dynamic data, such as device readbacks or
|
14
|
-
scan updates. By
|
15
|
-
using [`BECDispatcher`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher),
|
16
|
-
you
|
17
|
-
can create callback functions that react to incoming messages and update your widget's state or perform other tasks
|
18
|
-
based on the data received.
|
19
|
-
|
20
|
-
## How It Works
|
21
|
-
|
22
|
-
When you create a widget that needs to respond to updates from the BEC server, you can use
|
23
|
-
the [`BECDispatcher`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher)
|
24
|
-
to
|
25
|
-
connect specific Qt slots (callback functions) to message endpoints. These endpoints are defined within the BEC system
|
26
|
-
and represent specific channels of information (
|
27
|
-
e.g., [`device readback`](https://beamline-experiment-control.readthedocs.io/en/latest/api_reference/_autosummary/bec_lib.endpoints.MessageEndpoints.html#bec_lib.endpoints.MessageEndpoints.device_readback),
|
28
|
-
[`scan_segment`](https://beamline-experiment-control.readthedocs.io/en/latest/api_reference/_autosummary/bec_lib.endpoints.MessageEndpoints.html#bec_lib.endpoints.MessageEndpoints.scan_segment),
|
29
|
-
etc.).
|
30
|
-
|
31
|
-
### Step-by-Step Guide
|
32
|
-
|
33
|
-
1. **Create a Callback Function**: Define a function within your widget that will handle the data received from the BEC
|
34
|
-
server. This function should usually accept two parameters: `msg_content` (the message content) and `metadata` (
|
35
|
-
additional
|
36
|
-
information about the message).
|
37
|
-
|
38
|
-
```python
|
39
|
-
# Example for a callback function that updates a widget display based on motor readback data
|
40
|
-
from qtpy.QtCore import Slot
|
41
|
-
|
42
|
-
@Slot(dict, dict)
|
43
|
-
def on_device_readback(self, msg_content, metadata):
|
44
|
-
# Process the incoming data
|
45
|
-
new_value = msg_content["signals"]['motor_x']["value"]
|
46
|
-
# Update the widget's display or perform another action
|
47
|
-
self.update_display(new_value)
|
48
|
-
```
|
49
|
-
|
50
|
-
2. **Connect the Slot to an Endpoint**: Use
|
51
|
-
the [`BECDispatcher`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher)
|
52
|
-
to connect your callback function to a specific
|
53
|
-
endpoint. The endpoint represents the type of data or message you're interested in.
|
54
|
-
|
55
|
-
```python
|
56
|
-
from bec_lib.endpoints import MessageEndpoints
|
57
|
-
|
58
|
-
self.bec_dispatcher.connect_slot(self.on_device_readback, MessageEndpoints.device_readback("motor_x"))
|
59
|
-
```
|
60
|
-
|
61
|
-
3. **Handle Incoming Data**: Your callback function will be triggered automatically whenever a new message is received
|
62
|
-
on the connected endpoint. Use the data in `msg_content` to update your widget or perform other actions.
|
63
|
-
|
64
|
-
4. **Clean Up Connections**: If your widget is being destroyed or you no longer need to listen for updates, make sure to
|
65
|
-
disconnect your slots from
|
66
|
-
the [`BECDispatcher`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher)
|
67
|
-
to avoid memory or thread leaks.
|
68
|
-
|
69
|
-
```python
|
70
|
-
self.bec_dispatcher.disconnect_slot(self.on_device_readback, MessageEndpoints.device_readback("motor_x"))
|
71
|
-
```
|
72
|
-
|
73
|
-
### Example: Motor Map Widget
|
74
|
-
|
75
|
-
The [`BECMotorMap`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.widgets.figure.plots.motor_map.motor_map.BECMotorMap.html#bec-widgets-widgets-figure-plots-motor-map-motor-map-becmotormap)
|
76
|
-
widget is a great example of
|
77
|
-
how [`BECDispatcher`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher)
|
78
|
-
can be used to handle real-time data updates. This
|
79
|
-
widget listens for updates on specific motor positions and dynamically updates the motor map display.
|
80
|
-
|
81
|
-
Here's a breakdown of
|
82
|
-
how [`BECDispatcher`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher)
|
83
|
-
is used in
|
84
|
-
the [`BECMotorMap`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.widgets.figure.plots.motor_map.motor_map.BECMotorMap.html#bec-widgets-widgets-figure-plots-motor-map-motor-map-becmotormap)
|
85
|
-
widget:
|
86
|
-
|
87
|
-
1. **Connecting to Motor Readbacks**:
|
88
|
-
The widget connects to
|
89
|
-
the [`device readback`](https://beamline-experiment-control.readthedocs.io/en/latest/api_reference/_autosummary/bec_lib.endpoints.MessageEndpoints.html#bec_lib.endpoints.MessageEndpoints.device_readback)
|
90
|
-
endpoints using
|
91
|
-
the [`connect_slot`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher.connect_slot)
|
92
|
-
method
|
93
|
-
of [`BECDispatcher`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher).
|
94
|
-
This allows
|
95
|
-
the widget to receive real-time updates about the motor positions.
|
96
|
-
|
97
|
-
```{literalinclude} ../../../bec_widgets/widgets/figure/plots/motor_map/motor_map.py
|
98
|
-
:language: python
|
99
|
-
:pyobject: BECMotorMap._connect_motor_to_slots
|
100
|
-
:dedent: 4
|
101
|
-
```
|
102
|
-
|
103
|
-
2. **Handling Readback Data**:
|
104
|
-
The `on_device_readback` slot is called whenever new data is received from the motor readback. This slot processes
|
105
|
-
the data and updates the motor map plot accordingly.
|
106
|
-
|
107
|
-
```{literalinclude} ../../../bec_widgets/widgets/figure/plots/motor_map/motor_map.py
|
108
|
-
:language: python
|
109
|
-
:pyobject: BECMotorMap.on_device_readback
|
110
|
-
:dedent: 4
|
111
|
-
```
|
112
|
-
|
113
|
-
3. **Updating the Plot**:
|
114
|
-
The motor map plot is updated in response to the new data, providing a real-time visualization of the motor's
|
115
|
-
position.
|
116
|
-
|
117
|
-
```{literalinclude} ../../../bec_widgets/widgets/figure/plots/motor_map/motor_map.py
|
118
|
-
:language: python
|
119
|
-
:pyobject: BECMotorMap._update_plot
|
120
|
-
:dedent: 4
|
121
|
-
```
|
122
|
-
|
123
|
-
4. **Disconnecting When No Longer Needed**:
|
124
|
-
The widget ensures that connections are properly cleaned up when no longer needed.
|
125
|
-
|
126
|
-
```{literalinclude} ../../../bec_widgets/widgets/figure/plots/motor_map/motor_map.py
|
127
|
-
:language: python
|
128
|
-
:pyobject: BECMotorMap._update_plot
|
129
|
-
:dedent: 4
|
130
|
-
```
|
131
|
-
|
132
|
-
## Conclusion
|
133
|
-
|
134
|
-
The [`BECDispatcher`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_dispatcher.BECDispatcher.html#bec_widgets.utils.bec_dispatcher.BECDispatcher)
|
135
|
-
is a key tool for developing interactive and responsive widgets within the BEC framework. By
|
136
|
-
leveraging this tool, you can create widgets that automatically respond to real-time data updates from the BEC server,
|
137
|
-
enhancing the interactivity and functionality of your user interface.
|
138
|
-
|
139
|
-
In next tutorials we will cover how to create a custom widget using the BECDispatcher and BECWidget base class.
|
140
|
-
|
141
|
-
```{note}
|
142
|
-
For more details on specific messages and endpoints, please refer to the [Message Endpoints Documentation](https://beamline-experiment-control.readthedocs.io/en/latest/api_reference/_autosummary/bec_lib.endpoints.MessageEndpoints.html#bec-lib-endpoints-messageendpoints).
|
143
|
-
```
|
@@ -1,171 +0,0 @@
|
|
1
|
-
(developer.widget_development.widget_base_class)=
|
2
|
-
|
3
|
-
# BECWidget Base Class
|
4
|
-
|
5
|
-
When developing new widgets, it is crucial to ensure seamless integration with the BEC system. This is achieved by using
|
6
|
-
the [`BECWidget`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_widget.BECWidget.html#bec_widgets.utils.bec_widget.BECWidget)
|
7
|
-
base class, which provides essential functionalities and shortcuts to interact with various BEC services. In this
|
8
|
-
tutorial, we will explore the importance of this base class, the role of
|
9
|
-
the [`BECConnector`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_connector.BECConnector.html#bec_widgets.utils.bec_connector.BECConnector)
|
10
|
-
mixin, and how these components work together to facilitate the development of powerful and responsive widgets.
|
11
|
-
|
12
|
-
## Understanding the `BECWidget` Base Class
|
13
|
-
|
14
|
-
The [`BECWidget`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_widget.BECWidget.html#bec_widgets.utils.bec_widget.BECWidget)
|
15
|
-
base class is designed to serve as the foundation for all BEC-connected widgets. It ensures that your widget is properly
|
16
|
-
integrated with the BEC system by providing:
|
17
|
-
|
18
|
-
1. **Connection to BEC Services
|
19
|
-
**: [`BECWidget`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_widget.BECWidget.html#bec_widgets.utils.bec_widget.BECWidget)
|
20
|
-
includes
|
21
|
-
the [`BECConnector`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_connector.BECConnector.html#bec_widgets.utils.bec_connector.BECConnector)
|
22
|
-
mixin, which handles all the necessary connections to BEC services such as the BEC server, device manager, scan
|
23
|
-
control, and more.
|
24
|
-
|
25
|
-
2. **Qt Integration**:
|
26
|
-
The [`BECWidget`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_widget.BECWidget.html#bec_widgets.utils.bec_widget.BECWidget)
|
27
|
-
base class also ensures that your widget is correctly integrated with Qt by requiring that it inherits from
|
28
|
-
both [`BECWidget`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_widget.BECWidget.html#bec_widgets.utils.bec_widget.BECWidget)
|
29
|
-
and [`QWidget`](https://doc.qt.io/qtforpython-6/PySide6/QtWidgets/QWidget.html). This combination allows your widget
|
30
|
-
to leverage the full power of Qt for creating rich user interfaces while staying connected to the BEC ecosystem.
|
31
|
-
|
32
|
-
3. **Configuration Management**: The base class provides a `ConnectionConfig` model (based on Pydantic) that helps
|
33
|
-
manage and validate the configuration of your widget. This configuration can be easily serialized to and from Python
|
34
|
-
dictionaries, JSON, or YAML formats, allowing for persistent storage and retrieval of widget states.
|
35
|
-
|
36
|
-
4. **RPC Registration**: Widgets derived
|
37
|
-
from [`BECWidget`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_widget.BECWidget.html#bec_widgets.utils.bec_widget.BECWidget)
|
38
|
-
are automatically registered with
|
39
|
-
the [`RPCRegister`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.cli.rpc_register.RPCRegister.html#bec_widgets.cli.rpc_register.RPCRegister),
|
40
|
-
enabling them to handle remote procedure calls (RPCs) efficiently. This allows the widget to be controlled remotely
|
41
|
-
from the `BECIPythonClient` via CLI, providing powerful control and automation capabilities. For example, you can
|
42
|
-
remotely adjust widget settings, start/stop operations, or query the widget’s status directly from the command line.
|
43
|
-
|
44
|
-
Here’s a basic example of a widget inheriting
|
45
|
-
from [`BECWidget`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_widget.BECWidget.html#bec_widgets.utils.bec_widget.BECWidget):
|
46
|
-
|
47
|
-
```python
|
48
|
-
from bec_widgets.utils.bec_widget import BECWidget
|
49
|
-
from qtpy.QtWidgets import QWidget, QVBoxLayout
|
50
|
-
|
51
|
-
|
52
|
-
class MyWidget(BECWidget, QWidget):
|
53
|
-
def __init__(self, parent=None, *args, **kwargs):
|
54
|
-
super().__init__(*args, **kwargs)
|
55
|
-
QWidget.__init__(self, parent=parent)
|
56
|
-
self.get_bec_shortcuts() # Initialize BEC shortcuts
|
57
|
-
self.init_ui()
|
58
|
-
|
59
|
-
def init_ui(self):
|
60
|
-
layout = QVBoxLayout(self)
|
61
|
-
# Add more UI components here
|
62
|
-
self.setLayout(layout)
|
63
|
-
```
|
64
|
-
|
65
|
-
### The Role of `BECConnector`
|
66
|
-
|
67
|
-
At the heart
|
68
|
-
of [`BECWidget`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_widget.BECWidget.html#bec_widgets.utils.bec_widget.BECWidget)
|
69
|
-
is
|
70
|
-
the [`BECConnector`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_connector.BECConnector.html#bec_widgets.utils.bec_connector.BECConnector)
|
71
|
-
mixin, which plays a crucial role in managing the connection between your widget and the BEC system.
|
72
|
-
The [`BECConnector`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_connector.BECConnector.html#bec_widgets.utils.bec_connector.BECConnector)
|
73
|
-
provides several key functionalities:
|
74
|
-
|
75
|
-
1. **Client Initialization**: It initializes a `BECClient` instance if one isn't provided, ensuring your widget is
|
76
|
-
connected to the BEC server. This client is central to all interactions with the BEC system.
|
77
|
-
|
78
|
-
2. **Task Management**:
|
79
|
-
The [`submit_task`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_connector.BECConnector.html#bec_widgets.utils.bec_connector.BECConnector.submit_task)
|
80
|
-
method allows for running tasks in separate threads, preventing long-running operations from blocking the main UI
|
81
|
-
thread.
|
82
|
-
|
83
|
-
3. **Configuration Handling
|
84
|
-
**: [`BECConnector`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_connector.BECConnector.html#bec_widgets.utils.bec_connector.BECConnector)
|
85
|
-
uses the `ConnectionConfig` model to manage the widget’s configuration, ensuring all parameters are validated and
|
86
|
-
properly set up.
|
87
|
-
|
88
|
-
4. **RPC Registration**: Widgets are registered with
|
89
|
-
the [`RPCRegister`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.cli.rpc_register.RPCRegister.html#bec-widgets-cli-rpc-register-rpcregister),
|
90
|
-
allowing them to handle remote procedure calls effectively.
|
91
|
-
|
92
|
-
5. **Error Handling**: It includes utilities for handling errors gracefully within the Qt environment, ensuring that
|
93
|
-
issues are reported to the user without crashing the application.
|
94
|
-
|
95
|
-
### Utilizing `get_bec_shortcuts`
|
96
|
-
|
97
|
-
One of the most powerful features of
|
98
|
-
the [`BECConnector`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_connector.BECConnector.html#bec_widgets.utils.bec_connector.BECConnector)
|
99
|
-
is the `get_bec_shortcuts` method. This method provides your widget with direct access to essential components of the
|
100
|
-
BEC system through convenient shortcuts:
|
101
|
-
|
102
|
-
1. **Device Manager (`self.dev`)**:
|
103
|
-
- Access all devices registered with the BEC system. You can interact with devices, retrieve their status, and send
|
104
|
-
commands directly through this shortcut.
|
105
|
-
```python
|
106
|
-
# Moves 'motor1' to position 10
|
107
|
-
self.dev["motor1"].move(10)
|
108
|
-
```
|
109
|
-
|
110
|
-
2. **Scan Control (`self.scans`)**:
|
111
|
-
- Control scans, initiate new ones, monitor progress, and manage their execution.
|
112
|
-
```python
|
113
|
-
# Starts Line Scan from -10 to 10 in samx and -5 to 5 in samy
|
114
|
-
self.scans.line_scan(self.dev.samx,-10,10,self.dev.samy,-5,5, steps=100, exp_time=0.001,relative=False)
|
115
|
-
```
|
116
|
-
|
117
|
-
3. **Queue Management (`self.queue`)**:
|
118
|
-
- Manage the BEC scan queue, such as adding scans, checking status, or removing scans.
|
119
|
-
```python
|
120
|
-
# Request abortion of the current scan queue
|
121
|
-
self.queue.request_scan_abortion()
|
122
|
-
```
|
123
|
-
|
124
|
-
4. **Scan Storage (`self.scan_storage`)**:
|
125
|
-
- Access stored scan data for retrieval and analysis.
|
126
|
-
```python
|
127
|
-
# Retrieve scan item for a specific scan ID
|
128
|
-
self.scan_item = self.queue.scan_storage.find_scan_by_ID(self.scan_id)
|
129
|
-
```
|
130
|
-
|
131
|
-
5. **Full BECClient Access (`self.client`)**:
|
132
|
-
- Direct access to the BECClient instance, allowing for additional functionalities not covered by the shortcuts.
|
133
|
-
```python
|
134
|
-
# Shutdown the BECClient
|
135
|
-
self.client.shutdown()
|
136
|
-
```
|
137
|
-
|
138
|
-
### Example: `PositionerBox` Widget
|
139
|
-
|
140
|
-
Let’s look at an example of a widget that leverages
|
141
|
-
the [`BECWidget`](https://bec.readthedocs.io/projects/bec-widgets/en/latest/api_reference/_autosummary/bec_widgets.utils.bec_widget.BECWidget.html#bec_widgets.utils.bec_widget.BECWidget)
|
142
|
-
base class and `get_bec_shortcuts`:
|
143
|
-
|
144
|
-
````{dropdown} View code: PositionerBox Widget
|
145
|
-
:icon: code-square
|
146
|
-
:animate: fade-in-slide-down
|
147
|
-
```{literalinclude} ../../../bec_widgets/widgets/positioner_box/positioner_box.py
|
148
|
-
:language: python
|
149
|
-
:pyobject: PositionerBox
|
150
|
-
```
|
151
|
-
````
|
152
|
-
|
153
|
-
In this widget:
|
154
|
-
|
155
|
-
- **Device Interaction**: The widget uses `self.dev` to interact with a positioner device, reading its state and
|
156
|
-
updating the UI accordingly.
|
157
|
-
|
158
|
-
- **Scan and Queue Control**: Although not shown in this example, the widget could easily use `self.scans`
|
159
|
-
and `self.queue` to manage scans related to the positioner or queue up new operations.
|
160
|
-
|
161
|
-
### Conclusion
|
162
|
-
|
163
|
-
The `BECWidget` base class and the `BECConnector` mixin are foundational components for creating widgets that seamlessly
|
164
|
-
integrate with the BEC system. By inheriting from `BECWidget`, you gain access to powerful connection management, task
|
165
|
-
handling, and configuration capabilities, as well as shortcuts that make interacting with BEC services straightforward
|
166
|
-
and efficient.
|
167
|
-
|
168
|
-
By leveraging these tools, you can focus on building the core functionality of your widget, confident that the
|
169
|
-
complexities of BEC integration are handled robustly and efficiently. In the next tutorial we will demonstrate
|
170
|
-
step-by-step how to create a custom widget using the `BECWidget` base class and explore advanced features for creating
|
171
|
-
responsive and interactive user interfaces.
|
@@ -1,14 +0,0 @@
|
|
1
|
-
(developer.widget_development)=
|
2
|
-
|
3
|
-
# Widget Development
|
4
|
-
This section provides an introduction to the building blocks of BEC Widgets: widgets. Widgets are the basic components of the graphical user interface (GUI) and are used to create larger applications. We will cover key topics such as how to develop new widgets or how to customise existing widgets. For details on the already available widgets and their usage, please refer to user section about [widgets](#user.widgets)
|
5
|
-
|
6
|
-
```{toctree}
|
7
|
-
---
|
8
|
-
maxdepth: 2
|
9
|
-
hidden: false
|
10
|
-
---
|
11
|
-
|
12
|
-
bec_dispatcher
|
13
|
-
widget_base_class
|
14
|
-
```
|
docs/index.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
:html_theme.sidebar_secondary.remove:
|
2
|
-
|
3
|
-
# BEC Widgets documentation
|
4
|
-
|
5
|
-
A flexible and extensible framework for building graphical user interfaces in Python, optimized for use in the BEC environment.
|
6
|
-
|
7
|
-
<br><br>
|
8
|
-
|
9
|
-
````{grid} 2
|
10
|
-
:gutter: 5
|
11
|
-
|
12
|
-
```{grid-item-card}
|
13
|
-
:link: introduction
|
14
|
-
:link-type: ref
|
15
|
-
:img-top: /assets/index_getting_started.svg
|
16
|
-
:text-align: center
|
17
|
-
:class-item: index-card
|
18
|
-
|
19
|
-
## Introduction
|
20
|
-
|
21
|
-
General information about BEC Widgets.
|
22
|
-
```
|
23
|
-
|
24
|
-
```{grid-item-card}
|
25
|
-
:link: user
|
26
|
-
:link-type: ref
|
27
|
-
:img-top: /assets/index_user_guide.svg
|
28
|
-
:text-align: center
|
29
|
-
:class-item: index-card
|
30
|
-
|
31
|
-
## User guide
|
32
|
-
|
33
|
-
Information for users of BEC Widgets.
|
34
|
-
```
|
35
|
-
|
36
|
-
```{grid-item-card}
|
37
|
-
:link: developer
|
38
|
-
:link-type: ref
|
39
|
-
:img-top: /assets/index_contribute.svg
|
40
|
-
:text-align: center
|
41
|
-
:class-item: index-card
|
42
|
-
|
43
|
-
## Developer guide
|
44
|
-
|
45
|
-
Information for developers of BEC Widgets.
|
46
|
-
```
|
47
|
-
|
48
|
-
```{grid-item-card}
|
49
|
-
:link: api_reference
|
50
|
-
:link-type: ref
|
51
|
-
:img-top: /assets/index_api.svg
|
52
|
-
:text-align: center
|
53
|
-
:class-item: index-card
|
54
|
-
|
55
|
-
## API reference
|
56
|
-
|
57
|
-
Comprehensive reference of all BEC Widget classes, functions, and methods.
|
58
|
-
```
|
59
|
-
|
60
|
-
````
|
61
|
-
|
62
|
-
|
63
|
-
```{toctree}
|
64
|
-
---
|
65
|
-
numbered: true
|
66
|
-
maxdepth: 2
|
67
|
-
hidden: true
|
68
|
-
---
|
69
|
-
|
70
|
-
introduction/introduction
|
71
|
-
user/user
|
72
|
-
developer/developer
|
73
|
-
api_reference/api_reference
|
74
|
-
```
|
@@ -1,18 +0,0 @@
|
|
1
|
-
(introduction)=
|
2
|
-
# Introduction
|
3
|
-
|
4
|
-
## Overview
|
5
|
-
|
6
|
-
BEC Widgets is a GUI framework developed with beamline scientists in mind, aiming to provide a modern and modular environment for interacting with experiments. This package offers a suite of widgets specifically designed to enhance the workflow of beamline experiments, including features for running scans and data visualization.
|
7
|
-
|
8
|
-
Targeting the unique needs of beamline scientists, BEC Widgets stands out with its modular approach to widget design and high customizability. This flexibility allows for tailored solutions that meet the specific requirements of each beamline.
|
9
|
-
|
10
|
-
**Key Features**:
|
11
|
-
|
12
|
-
- **Integration:** Seamlessly integrates with [BEC (Beamline Experiment Control)](https://gitlab.psi.ch/bec/bec), ensuring a cohesive and efficient experiment control experience.
|
13
|
-
- **Support for Pyside6 and PyQt6:** Provides compatibility with both Pyside6 and PyQt6, offering versatility in your development environment.
|
14
|
-
- **Widget Modularity:** Features modular widgets that can be easily combined to create customized applications, perfectly aligning with the diverse needs of beamline experiments.
|
15
|
-
|
16
|
-
## Getting Started
|
17
|
-
|
18
|
-
For detailed usage instructions and examples showcasing the practical applications of BEC Widgets, please refer to the [User](#user) section. Developers interested in contributing or customizing BEC Widgets can find more information in the [Developer](#developer) section.
|
docs/make.bat
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
@ECHO OFF
|
2
|
-
|
3
|
-
pushd %~dp0
|
4
|
-
|
5
|
-
REM Command file for Sphinx documentation
|
6
|
-
|
7
|
-
if "%SPHINXBUILD%" == "" (
|
8
|
-
set SPHINXBUILD=sphinx-build
|
9
|
-
)
|
10
|
-
set SOURCEDIR=.
|
11
|
-
set BUILDDIR=_build
|
12
|
-
|
13
|
-
%SPHINXBUILD% >NUL 2>NUL
|
14
|
-
if errorlevel 9009 (
|
15
|
-
echo.
|
16
|
-
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
17
|
-
echo.installed, then set the SPHINXBUILD environment variable to point
|
18
|
-
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
19
|
-
echo.may add the Sphinx directory to PATH.
|
20
|
-
echo.
|
21
|
-
echo.If you don't have Sphinx installed, grab it from
|
22
|
-
echo.https://www.sphinx-doc.org/
|
23
|
-
exit /b 1
|
24
|
-
)
|
25
|
-
|
26
|
-
if "%1" == "" goto help
|
27
|
-
|
28
|
-
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
29
|
-
goto end
|
30
|
-
|
31
|
-
:help
|
32
|
-
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
33
|
-
|
34
|
-
:end
|
35
|
-
popd
|
docs/requirements.txt
DELETED