bec-widgets 0.99.8__py3-none-any.whl → 0.99.9__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.
Files changed (155) hide show
  1. CHANGELOG.md +6 -6
  2. PKG-INFO +1 -1
  3. {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.9.dist-info}/METADATA +1 -1
  4. {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.9.dist-info}/RECORD +8 -155
  5. pyproject.toml +6 -1
  6. docs/Makefile +0 -20
  7. docs/_static/custom.css +0 -170
  8. docs/_templates/custom-class-template.rst +0 -34
  9. docs/_templates/custom-module-template.rst +0 -66
  10. docs/api_reference/api_reference.md +0 -12
  11. docs/assets/apps_48dp.svg +0 -1
  12. docs/assets/display_settings_48dp.svg +0 -1
  13. docs/assets/index_api.svg +0 -97
  14. docs/assets/index_contribute.svg +0 -76
  15. docs/assets/index_getting_started.svg +0 -66
  16. docs/assets/index_user_guide.svg +0 -67
  17. docs/assets/rocket_launch_48dp.svg +0 -1
  18. docs/assets/widget_screenshots/buttons.png +0 -0
  19. docs/assets/widget_screenshots/device_box.png +0 -0
  20. docs/assets/widget_screenshots/device_browser.png +0 -0
  21. docs/assets/widget_screenshots/device_inputs.png +0 -0
  22. docs/assets/widget_screenshots/dock_area.png +0 -0
  23. docs/assets/widget_screenshots/figure.png +0 -0
  24. docs/assets/widget_screenshots/image_widget.png +0 -0
  25. docs/assets/widget_screenshots/motor_map_widget.png +0 -0
  26. docs/assets/widget_screenshots/position_indicator.png +0 -0
  27. docs/assets/widget_screenshots/queue.png +0 -0
  28. docs/assets/widget_screenshots/ring_progress_bar.png +0 -0
  29. docs/assets/widget_screenshots/scan_controller.png +0 -0
  30. docs/assets/widget_screenshots/spinner.gif +0 -0
  31. docs/assets/widget_screenshots/status_box.png +0 -0
  32. docs/assets/widget_screenshots/text_box.png +0 -0
  33. docs/assets/widget_screenshots/toggle.png +0 -0
  34. docs/assets/widget_screenshots/waveform_widget.png +0 -0
  35. docs/assets/widget_screenshots/website.png +0 -0
  36. docs/conf.py +0 -82
  37. docs/developer/developer.md +0 -52
  38. docs/developer/introduction/concepts.md +0 -14
  39. docs/developer/introduction/contributing.md +0 -28
  40. docs/developer/introduction/introduction.md +0 -16
  41. docs/developer/introduction/useful_links.md +0 -23
  42. docs/developer/widget_development/bec_dispatcher.md +0 -143
  43. docs/developer/widget_development/widget_base_class.md +0 -171
  44. docs/developer/widget_development/widget_development.md +0 -14
  45. docs/index.md +0 -74
  46. docs/introduction/introduction.md +0 -18
  47. docs/make.bat +0 -35
  48. docs/requirements.txt +0 -12
  49. docs/user/api_reference/api_reference.md +0 -11
  50. docs/user/applications/applications.md +0 -10
  51. docs/user/customisation.md +0 -123
  52. docs/user/getting_started/BECDockArea.png +0 -0
  53. docs/user/getting_started/auto_updates.md +0 -82
  54. docs/user/getting_started/getting_started.md +0 -15
  55. docs/user/getting_started/gui_complex_gui.gif +0 -0
  56. docs/user/getting_started/installation.md +0 -33
  57. docs/user/getting_started/quick_start.md +0 -110
  58. docs/user/getting_started/video_tutorials.md +0 -17
  59. docs/user/user.md +0 -71
  60. docs/user/widgets/bec_figure/BECFigure.png +0 -0
  61. docs/user/widgets/bec_figure/bec_figure.md +0 -105
  62. docs/user/widgets/bec_status_box/bec_status_box.gif +0 -0
  63. docs/user/widgets/bec_status_box/bec_status_box.md +0 -38
  64. docs/user/widgets/buttons/buttons.md +0 -90
  65. docs/user/widgets/buttons/dark_mode_disabled.png +0 -0
  66. docs/user/widgets/buttons/dark_mode_enabled.png +0 -0
  67. docs/user/widgets/device_browser/device_browser.md +0 -36
  68. docs/user/widgets/device_browser/device_browser.png +0 -0
  69. docs/user/widgets/device_input/device_input.md +0 -100
  70. docs/user/widgets/dock_area/BECDockArea.png +0 -0
  71. docs/user/widgets/dock_area/bec_dock_area.md +0 -109
  72. docs/user/widgets/image/image_plot.gif +0 -0
  73. docs/user/widgets/image/image_widget.md +0 -84
  74. docs/user/widgets/motor_map/motor.gif +0 -0
  75. docs/user/widgets/motor_map/motor_map.md +0 -80
  76. docs/user/widgets/position_indicator/position_indicator.md +0 -69
  77. docs/user/widgets/positioner_box/positioner_box.md +0 -63
  78. docs/user/widgets/progress_bar/progress_bar.gif +0 -0
  79. docs/user/widgets/progress_bar/ring_progress_bar.md +0 -103
  80. docs/user/widgets/queue/queue.md +0 -41
  81. docs/user/widgets/scan_control/hide_scan_control.png +0 -0
  82. docs/user/widgets/scan_control/scan_control.gif +0 -0
  83. docs/user/widgets/scan_control/scan_control.md +0 -54
  84. docs/user/widgets/spinner/spinner.md +0 -68
  85. docs/user/widgets/text_box/text_box.md +0 -74
  86. docs/user/widgets/toggle/toggle.md +0 -66
  87. docs/user/widgets/waveform/bec_figure_dap.gif +0 -0
  88. docs/user/widgets/waveform/scatter_2D.gif +0 -0
  89. docs/user/widgets/waveform/w1D.gif +0 -0
  90. docs/user/widgets/waveform/waveform_widget.md +0 -132
  91. docs/user/widgets/website/website.md +0 -69
  92. docs/user/widgets/widgets.md +0 -220
  93. tests/__init__.py +0 -0
  94. tests/end-2-end/__init__.py +0 -0
  95. tests/end-2-end/conftest.py +0 -53
  96. tests/end-2-end/test_bec_dock_rpc_e2e.py +0 -298
  97. tests/end-2-end/test_bec_figure_rpc_e2e.py +0 -212
  98. tests/end-2-end/test_rpc_register_e2e.py +0 -40
  99. tests/end-2-end/test_scan_control_e2e.py +0 -71
  100. tests/references/SpinnerWidget/SpinnerWidget_darwin.png +0 -0
  101. tests/references/SpinnerWidget/SpinnerWidget_linux.png +0 -0
  102. tests/references/SpinnerWidget/SpinnerWidget_started_darwin.png +0 -0
  103. tests/references/SpinnerWidget/SpinnerWidget_started_linux.png +0 -0
  104. tests/unit_tests/__init__.py +0 -0
  105. tests/unit_tests/client_mocks.py +0 -189
  106. tests/unit_tests/conftest.py +0 -64
  107. tests/unit_tests/test_bec_connector.py +0 -80
  108. tests/unit_tests/test_bec_dispatcher.py +0 -119
  109. tests/unit_tests/test_bec_dock.py +0 -155
  110. tests/unit_tests/test_bec_figure.py +0 -270
  111. tests/unit_tests/test_bec_image.py +0 -63
  112. tests/unit_tests/test_bec_image_widget.py +0 -217
  113. tests/unit_tests/test_bec_motor_map.py +0 -282
  114. tests/unit_tests/test_bec_queue.py +0 -111
  115. tests/unit_tests/test_bec_status_box.py +0 -123
  116. tests/unit_tests/test_client_utils.py +0 -76
  117. tests/unit_tests/test_color_map_selector.py +0 -42
  118. tests/unit_tests/test_color_validation.py +0 -75
  119. tests/unit_tests/test_configs/config_device.yaml +0 -33
  120. tests/unit_tests/test_configs/config_device_no_entry.yaml +0 -27
  121. tests/unit_tests/test_configs/config_scan.yaml +0 -82
  122. tests/unit_tests/test_crosshair.py +0 -143
  123. tests/unit_tests/test_dark_mode_button.py +0 -70
  124. tests/unit_tests/test_device_browser.py +0 -83
  125. tests/unit_tests/test_device_input_base.py +0 -76
  126. tests/unit_tests/test_device_input_widgets.py +0 -178
  127. tests/unit_tests/test_error_utils.py +0 -63
  128. tests/unit_tests/test_generate_cli_client.py +0 -123
  129. tests/unit_tests/test_generate_plugin.py +0 -155
  130. tests/unit_tests/test_motor_map_widget.py +0 -194
  131. tests/unit_tests/test_msgs/__init__.py +0 -0
  132. tests/unit_tests/test_msgs/available_scans_message.py +0 -989
  133. tests/unit_tests/test_plot_base.py +0 -95
  134. tests/unit_tests/test_plugin_utils.py +0 -13
  135. tests/unit_tests/test_positioner_box.py +0 -130
  136. tests/unit_tests/test_ring_progress_bar.py +0 -337
  137. tests/unit_tests/test_rpc_register.py +0 -52
  138. tests/unit_tests/test_rpc_server.py +0 -42
  139. tests/unit_tests/test_rpc_widget_handler.py +0 -7
  140. tests/unit_tests/test_scan_control.py +0 -324
  141. tests/unit_tests/test_scan_control_group_box.py +0 -160
  142. tests/unit_tests/test_setting_dialog.py +0 -96
  143. tests/unit_tests/test_spinner.py +0 -31
  144. tests/unit_tests/test_stop_button.py +0 -27
  145. tests/unit_tests/test_text_box_widget.py +0 -54
  146. tests/unit_tests/test_toggle.py +0 -38
  147. tests/unit_tests/test_vscode_widget.py +0 -75
  148. tests/unit_tests/test_waveform1d.py +0 -712
  149. tests/unit_tests/test_waveform_widget.py +0 -462
  150. tests/unit_tests/test_website_widget.py +0 -25
  151. tests/unit_tests/test_widget_io.py +0 -90
  152. tests/unit_tests/test_yaml_dialog.py +0 -163
  153. {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.9.dist-info}/WHEEL +0 -0
  154. {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.9.dist-info}/entry_points.txt +0 -0
  155. {bec_widgets-0.99.8.dist-info → bec_widgets-0.99.9.dist-info}/licenses/LICENSE +0 -0
@@ -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
@@ -1,12 +0,0 @@
1
- sphinx
2
- sphinx_copybutton
3
- recommonmark
4
- sphinx-toolbox
5
- pydata-sphinx-theme
6
- sphinx-copybutton
7
- sphinx-inline-tabs
8
- myst-parser
9
- sphinx-design
10
- PySide6
11
- bec-widgets
12
- tomli
@@ -1,11 +0,0 @@
1
- (user.api_reference)=
2
- # User API Reference
3
-
4
- ```{eval-rst}
5
- .. autosummary::
6
- :toctree: _autosummary
7
- :template: custom-module-template.rst
8
-
9
- bec_widgets.cli.client
10
-
11
- ```
@@ -1,10 +0,0 @@
1
- (user.applications)=
2
- # Applications
3
-
4
- **Coming soon**
5
-
6
- ```{toctree}
7
- ---
8
- maxdepth: 1
9
- hidden: true
10
- ---
@@ -1,123 +0,0 @@
1
- (user.customisation)=
2
- # Customisation
3
-
4
- ## Leveraging BEC Widgets in custom GUI applications
5
-
6
- BEC Widgets can be used to compose a complete Qt graphical application, along with
7
- other QWidgets. The only requirement is to connect to BEC servers in order to get
8
- data, or to interact with BEC components. This role is devoted to the BECDispatcher,
9
- a singleton object which has to be instantiated **after the QApplication is created**.
10
-
11
- A typical BEC Widgets custom application "main" entry point should follow the template
12
- below:
13
-
14
- ```
15
- import argparse
16
- import sys
17
-
18
- from bec_widgets.utils.bec_dispatcher import BECDispatcher
19
- from qtpy.QtWidgets import QApplication
20
-
21
- # optional command line arguments processing
22
- parser = argparse.ArgumentParser(description="...")
23
- parser.add_argument( ...)
24
- ...
25
- args = parser.parse_args()
26
-
27
- # creation of the Qt application
28
- app = QApplication([])
29
-
30
- # creation of BEC Dispatcher
31
- # /!\ important: after the QApplication has been instantiated
32
- bec_dispatcher = BECDispatcher()
33
- client = bec_dispatcher.client
34
- client.start()
35
-
36
- # (optional) processing of command line args,
37
- # creation of a main window depending on the command line arguments (or not)
38
- if args.xxx == "...":
39
- window = ...
40
-
41
- # display of the main window and start of Qt event loop
42
- window.show()
43
- sys.exit(app.exec())
44
- ```
45
-
46
- The main "window" object presents the layout of widgets to the user and allows
47
- users to interact. BEC Widgets must be placed in the window:
48
-
49
- ```
50
- from qtpy.QWidgets import QMainWindow
51
- from bec_widgets.widgets.figure import BECFigure
52
-
53
- window = QMainWindow()
54
- bec_figure = BECFigure(gui_id="my_gui_app_id")
55
- window.setCentralWidget(bec_figure)
56
-
57
- # prepare to plot samx motor vs bpm4i value
58
- bec_figure.plot(x_name="samx", y_name="bpm4i")
59
- ```
60
-
61
- In the example just above, the resulting application will show a plot of samx
62
- positions on the horizontal axis, and beam intensity on the vertical axis
63
- (when the next scan will be started).
64
-
65
- It is important to ensure proper cleanup of the resources is done when application
66
- quits:
67
-
68
- ```
69
- def final_cleanup():
70
- bec_figure.clear_all()
71
- bec_figure.client.shutdown()
72
-
73
- window.aboutToQuit.connect(final_cleanup)
74
- ```
75
-
76
- Final example:
77
-
78
- ```
79
- import sys
80
- from qtpy.QtWidgets import QMainWindow, QApplication
81
- from bec_widgets.widgets.figure import BECFigure
82
- from bec_widgets.utils.bec_dispatcher import BECDispatcher
83
-
84
- # creation of the Qt application
85
- app = QApplication([])
86
-
87
- # creation of BEC Dispatcher
88
- bec_dispatcher = BECDispatcher()
89
- client = bec_dispatcher.client
90
- client.start()
91
-
92
- # creation of main window
93
- window = QMainWindow()
94
-
95
- # inserting BEC Widgets
96
- bec_figure = BECFigure(parent=window, gui_id="my_gui_app_id")
97
- window.setCentralWidget(bec_figure)
98
-
99
- bec_figure.plot(x_name="samx", y_name="bpm4i")
100
-
101
- # ensuring proper cleanup
102
- def final_cleanup():
103
- bec_figure.clear_all()
104
- bec_figure.client.shutdown()
105
-
106
- app.aboutToQuit.connect(final_cleanup)
107
-
108
- # execution
109
- window.show()
110
- sys.exit(app.exec())
111
- ```
112
-
113
- ## Writing applications using Qt Designer
114
-
115
- BEC Widgets are designed to be used with QtDesigner to quickly design GUI.
116
-
117
- ## Example of promoting widgets in Qt Designer
118
-
119
- _Work in progress_
120
-
121
- ## Implementation of plugins into Qt Designer
122
-
123
- _Work in progress_
Binary file