bec-widgets 0.57.2__py3-none-any.whl → 0.57.3__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 CHANGED
@@ -2,6 +2,29 @@
2
2
 
3
3
 
4
4
 
5
+ ## v0.57.3 (2024-06-06)
6
+
7
+ ### Documentation
8
+
9
+ * docs(bar): docs updated ([`4be0d14`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/4be0d14b7445c2322c2aef86257db168a841265c))
10
+
11
+ * docs: fixed syntax of add_widget ([`a951ebf`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/a951ebf1be6c086d094aa8abef5e0dfd1b3b8558))
12
+
13
+ * docs: added auto update; closes #206 ([`32da803`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/32da803df9f7259842c43e85ba9a0ce29a266d06))
14
+
15
+ * docs: cleanup ([`07d60cf`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/07d60cf7355d2edadb3c5ef8b86607d74b360455))
16
+
17
+ ### Fix
18
+
19
+ * fix(ring): automatic updates are disabled uf user specify updates manually with .set_update; 'scan_progres' do not reset number of rings ([`e883dba`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/e883dbad814dbcc0a19c341041c6d836e58a5918))
20
+
21
+ * fix(ring): enable_auto_updates(True) do not reset properties of already setup bars ([`a2abad3`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/a2abad344f4c0039516eb60a825afb6822c5b19a))
22
+
23
+ * fix(ring): set_min_max accepts floats ([`d44b1cf`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/d44b1cf8b107cf02deedd9154b77d01c7f9ed05d))
24
+
25
+ * fix(ring): set_update changed to Literals, no need to specify endpoint manually ([`c5b6499`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c5b6499e41eb1495bf260436ca3e1b036182c360))
26
+
27
+
5
28
  ## v0.57.2 (2024-06-06)
6
29
 
7
30
  ### Fix
@@ -136,32 +159,3 @@
136
159
  ### Fix
137
160
 
138
161
  * fix: removed apparently unnecessary sleep while waiting for an rpc response ([`7d64cac`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/7d64cac6610b39d3553ff650354f78ead8ee6b55))
139
-
140
-
141
- ## v0.53.2 (2024-05-15)
142
-
143
- ### Ci
144
-
145
- * ci: added echo to highlight the current branch ([`0490e80`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/0490e80c48563e4fb486bce903b3ce1f08863e83))
146
-
147
- ### Fix
148
-
149
- * fix: check device class without importing to speed up initial import time ([`9f8fbdd`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/9f8fbdd5fc13cf2be10eacb41e10cf742864cd92))
150
-
151
- * fix: speed up initial import times using lazy import (from bec_lib) ([`d1e6cd3`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/d1e6cd388c6c9f345f52d6096d8a75a1fa7e6934))
152
-
153
- * fix: adapt to bec_lib changes (no more submodules in `__init__.py`) ([`5d09a13`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/5d09a13d8820a8bdb900733c97593b723a2fce1d))
154
-
155
-
156
- ## v0.53.1 (2024-05-09)
157
-
158
- ### Ci
159
-
160
- * ci: fixed rtd pages url ([`8ff3610`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/8ff36105d1e637c429915b4bfc2852d54a3c6f19))
161
-
162
- ### Fix
163
-
164
- * fix: docs config ([`0f6a5e5`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/0f6a5e5fa9530969c98a9266c9ca7b89a378ff70))
165
-
166
-
167
- ## v0.53.0 (2024-05-09)
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.57.2
3
+ Version: 0.57.3
4
4
  Summary: BEC Widgets
5
5
  Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec_widgets/issues
6
6
  Project-URL: Homepage, https://gitlab.psi.ch/bec/bec_widgets
bec_widgets/cli/client.py CHANGED
@@ -1890,7 +1890,7 @@ class Ring(RPCBase):
1890
1890
  """
1891
1891
 
1892
1892
  @rpc_call
1893
- def set_min_max_values(self, min_value: "int", max_value: "int"):
1893
+ def set_min_max_values(self, min_value: "int | float", max_value: "int | float"):
1894
1894
  """
1895
1895
  None
1896
1896
  """
@@ -1902,9 +1902,13 @@ class Ring(RPCBase):
1902
1902
  """
1903
1903
 
1904
1904
  @rpc_call
1905
- def set_connections(self, slot: "str", endpoint: "str | EndpointInfo"):
1905
+ def set_update(self, mode: "Literal['manual', 'scan', 'device']", device: "str" = None):
1906
1906
  """
1907
- None
1907
+ Set the update mode for the ring widget
1908
+
1909
+ Args:
1910
+ mode(str): Update mode for the ring widget. Can be "manual", "scan" or "device"
1911
+ device(str): Device name for the device readback mode, only used when mode is "device"
1908
1912
  """
1909
1913
 
1910
1914
  @rpc_call
@@ -49,7 +49,7 @@ class RingConfig(ConnectionConfig):
49
49
  description="Background color for the progress bars. Can be tuple (R, G, B, A) or string HEX Code.",
50
50
  )
51
51
  index: int | None = Field(0, description="Index of the progress bar. 0 is outer ring.")
52
- line_width: int | None = Field(5, description="Line widths for the progress bars.")
52
+ line_width: int | None = Field(10, description="Line widths for the progress bars.")
53
53
  start_position: int | None = Field(
54
54
  90,
55
55
  description="Start position for the progress bars in degrees. Default is 90 degrees - corespons to "
@@ -77,7 +77,7 @@ class Ring(BECConnector):
77
77
  "set_line_width",
78
78
  "set_min_max_values",
79
79
  "set_start_angle",
80
- "set_connections",
80
+ "set_update",
81
81
  "reset_connection",
82
82
  ]
83
83
 
@@ -130,7 +130,7 @@ class Ring(BECConnector):
130
130
  def set_line_width(self, width: int):
131
131
  self.config.line_width = width
132
132
 
133
- def set_min_max_values(self, min_value: int, max_value: int):
133
+ def set_min_max_values(self, min_value: int | float, max_value: int | float):
134
134
  self.config.min_value = min_value
135
135
  self.config.max_value = max_value
136
136
 
@@ -147,6 +147,27 @@ class Ring(BECConnector):
147
147
  converted_color = QtGui.QColor(*color)
148
148
  return converted_color
149
149
 
150
+ def set_update(self, mode: Literal["manual", "scan", "device"], device: str = None):
151
+ """
152
+ Set the update mode for the ring widget
153
+
154
+ Args:
155
+ mode(str): Update mode for the ring widget. Can be "manual", "scan" or "device"
156
+ device(str): Device name for the device readback mode, only used when mode is "device"
157
+ """
158
+ if mode == "manual":
159
+ self.bec_dispatcher.disconnect_slot(
160
+ getattr(self, self.config.connections.slot), self.config.connections.endpoint
161
+ )
162
+ self.config.connections.slot = None
163
+ self.config.connections.endpoint = None
164
+ elif mode == "scan":
165
+ self.set_connections("on_scan_progress", "scans/scan_progress")
166
+ elif mode == "device":
167
+ self.set_connections("on_device_readback", f"internal/devices/readback/{device}")
168
+
169
+ self.parent_progress_widget.enable_auto_updates(False)
170
+
150
171
  def set_connections(self, slot: str, endpoint: str | EndpointInfo):
151
172
  if self.config.connections.endpoint == endpoint and self.config.connections.slot == slot:
152
173
  return
@@ -23,7 +23,7 @@ class SpiralProgressBarConfig(ConnectionConfig):
23
23
  10, description="Maximum number of progress bars to display."
24
24
  )
25
25
  num_bars: int | None = Field(1, description="Number of progress bars to display.")
26
- gap: int | None = Field(10, description="Gap between progress bars.")
26
+ gap: int | None = Field(20, description="Gap between progress bars.")
27
27
  auto_updates: bool | None = Field(
28
28
  True, description="Enable or disable updates based on scan queue status."
29
29
  )
@@ -118,7 +118,7 @@ class SpiralProgressBar(BECConnector, QWidget):
118
118
 
119
119
  # For updating bar behaviour
120
120
  self._auto_updates = True
121
- self._rings = []
121
+ self._rings = None
122
122
 
123
123
  if num_bars is not None:
124
124
  self.config.num_bars = max(
@@ -186,13 +186,22 @@ class SpiralProgressBar(BECConnector, QWidget):
186
186
  Ring: Ring object.
187
187
  """
188
188
  if self.config.num_bars < self.config.max_number_of_bars:
189
- ring = Ring(parent_progress_widget=self, **kwargs)
190
- ring.config.index = self.config.num_bars
189
+ ring_index = self.config.num_bars
190
+ ring_config = RingConfig(
191
+ widget_class="Ring",
192
+ index=ring_index,
193
+ start_positions=90 * 16,
194
+ directions=-1,
195
+ **kwargs,
196
+ )
197
+ ring = Ring(parent_progress_widget=self, config=ring_config)
191
198
  self.config.num_bars += 1
192
199
  self._rings.append(ring)
193
200
  self.config.rings.append(ring.config)
194
201
  if self.config.color_map:
195
202
  self.set_colors_from_map(self.config.color_map)
203
+ base_line_width = self._rings[ring.config.index].config.line_width
204
+ self.set_line_widths(base_line_width, ring.config.index)
196
205
  self.update()
197
206
  return ring
198
207
 
@@ -211,6 +220,7 @@ class SpiralProgressBar(BECConnector, QWidget):
211
220
  self._reindex_rings()
212
221
  if self.config.color_map:
213
222
  self.set_colors_from_map(self.config.color_map)
223
+ del ring
214
224
  self.update()
215
225
 
216
226
  def _reindex_rings(self):
@@ -269,9 +279,30 @@ class SpiralProgressBar(BECConnector, QWidget):
269
279
  num_bars = max(
270
280
  self.config.min_number_of_bars, min(num_bars, self.config.max_number_of_bars)
271
281
  )
272
- if num_bars != self.config.num_bars:
273
- self.config.num_bars = num_bars
274
- self.initialize_bars()
282
+ current_num_bars = self.config.num_bars
283
+
284
+ if num_bars > current_num_bars:
285
+ for i in range(current_num_bars, num_bars):
286
+ new_ring_config = RingConfig(
287
+ widget_class="Ring", index=i, start_positions=90 * 16, directions=-1
288
+ )
289
+ self.config.rings.append(new_ring_config)
290
+ new_ring = Ring(parent_progress_widget=self, config=new_ring_config)
291
+ self._rings.append(new_ring)
292
+
293
+ elif num_bars < current_num_bars:
294
+ for i in range(current_num_bars - 1, num_bars - 1, -1):
295
+ self.remove_ring(i)
296
+
297
+ self.config.num_bars = num_bars
298
+
299
+ if self.config.color_map:
300
+ self.set_colors_from_map(self.config.color_map)
301
+
302
+ base_line_width = self._rings[0].config.line_width
303
+ self.set_line_widths(base_line_width)
304
+
305
+ self.update()
275
306
 
276
307
  def set_value(self, values: int | list, ring_index: int = None):
277
308
  """
@@ -443,8 +474,6 @@ class SpiralProgressBar(BECConnector, QWidget):
443
474
  if report_instructions:
444
475
  instruction_type = list(report_instructions[0].keys())[0]
445
476
  if instruction_type == "scan_progress":
446
- if self.config.num_bars != 1:
447
- self.set_number_of_bars(1)
448
477
  self._hook_scan_progress(ring_index=0)
449
478
  elif instruction_type == "readback":
450
479
  devices = report_instructions[0].get("readback").get("devices")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.57.2
3
+ Version: 0.57.3
4
4
  Summary: BEC Widgets
5
5
  Project-URL: Bug Tracker, https://gitlab.psi.ch/bec/bec_widgets/issues
6
6
  Project-URL: Homepage, https://gitlab.psi.ch/bec/bec_widgets
@@ -2,11 +2,11 @@
2
2
  .gitlab-ci.yml,sha256=RF2JeGh8tG09DyAOwEu991IZy3C8Vm6lI8O_4Dr9B9Q,12239
3
3
  .pylintrc,sha256=OstrgmEyP0smNFBKoIN5_26-UmNZgMHnbjvAWX0UrLs,18535
4
4
  .readthedocs.yaml,sha256=aSOc277LqXcsTI6lgvm_JY80lMlr69GbPKgivua2cS0,603
5
- CHANGELOG.md,sha256=pG4sxxA4UKrOCZsHzC7nzYA5A7dwla6lFKnMujn04rQ,6889
5
+ CHANGELOG.md,sha256=5H1fQ0fZSKvNRSrVkZJ00ZkSff7DzKmFjg35jPc8vTg,7199
6
6
  LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
7
- PKG-INFO,sha256=VKjVy_MzeMyq50c2kmwfQ9hoe6abecAZIR6nSJcwVck,1178
7
+ PKG-INFO,sha256=NUwnybNOdIQRdfaJCymSOUpaYxAZhsEK9CIhk0hPz2I,1178
8
8
  README.md,sha256=y4jB6wvArS7N8_iTbKWnSM_oRAqLA2GqgzUR-FMh5sU,2645
9
- pyproject.toml,sha256=mYnyN3JxG1ULTqPhRsHj5xvuD0wUNtZydA6gaSddQSE,1822
9
+ pyproject.toml,sha256=ZLJ-JsjWQsfDxZAyCiSNk5Io50lUBDI-SlY562nGgEw,1822
10
10
  .git_hooks/pre-commit,sha256=n3RofIZHJl8zfJJIUomcMyYGFi_rwq4CC19z0snz3FI,286
11
11
  .gitlab/issue_templates/bug_report_template.md,sha256=gAuyEwl7XlnebBrkiJ9AqffSNOywmr8vygUFWKTuQeI,386
12
12
  .gitlab/issue_templates/documentation_update_template.md,sha256=FHLdb3TS_D9aL4CYZCjyXSulbaW5mrN2CmwTaeLPbNw,860
@@ -17,7 +17,7 @@ bec_widgets/assets/bec_widgets_icon.png,sha256=K8dgGwIjalDh9PRHUsSQBqgdX7a00nM3i
17
17
  bec_widgets/assets/terminal_icon.png,sha256=bJl7Tft4Fi2uxvuXI8o14uMHnI9eAWKSU2uftXCH9ws,3889
18
18
  bec_widgets/cli/__init__.py,sha256=tLD8HWgyURhMjYlKZ43pBu-qvGD1LI5o3n3rEieg-70,43
19
19
  bec_widgets/cli/auto_updates.py,sha256=8x4_SrD8Hh1RbrUWXLfisw6X5v8Mij2DiTfjvn9dkUw,4692
20
- bec_widgets/cli/client.py,sha256=DaBkuNB38XhOdNuAmd7UPaEy4kEWCgOdWWfMsPBsWAI,53089
20
+ bec_widgets/cli/client.py,sha256=E6t7gZzM3-YogkKdFz53PIXdHnkWhKyfSwRr2lu2hz0,53363
21
21
  bec_widgets/cli/client_utils.py,sha256=7u8P9EYgLPJuAcHxnFiZi-gCZohO3vAn0W7dqsSrs4M,10660
22
22
  bec_widgets/cli/generate_cli.py,sha256=tBt-F4Xccg9Pj2zuDEGHd0Ho1fKLfCf3PuSa8KmelQk,4431
23
23
  bec_widgets/cli/rpc_register.py,sha256=QxXUZu5XNg00Yf5O3UHWOXg3-f_pzKjjoZYMOa-MOJc,2216
@@ -82,8 +82,8 @@ bec_widgets/widgets/motor_control/selection/selection.ui,sha256=vXXpvNWuL6xyHhW7
82
82
  bec_widgets/widgets/scan_control/__init__.py,sha256=IOfHl15vxb_uC6KN62-PeUzbBha_vQyqkkXbJ2HU674,38
83
83
  bec_widgets/widgets/scan_control/scan_control.py,sha256=B5n2U2iVtTCY3Tx93JyBqzGCDCmWhWwAOhbPelLI-bs,17168
84
84
  bec_widgets/widgets/spiral_progress_bar/__init__.py,sha256=4efbtcqCToMIw5bkQrTzy2TzuBCXvlhuUPh1bYC_Yzg,51
85
- bec_widgets/widgets/spiral_progress_bar/ring.py,sha256=WlS3L3mSxFQNtc8T_XEPM7IoVeXYnM2SE5ImjvX6kJU,7097
86
- bec_widgets/widgets/spiral_progress_bar/spiral_progress_bar.py,sha256=AjQsZDEqPlTn0kE4xkYKOj2ae5vJ9gW-k3yz1Y32vsY,22543
85
+ bec_widgets/widgets/spiral_progress_bar/ring.py,sha256=zYz_wq5f-mfI32_melkxyzMbx4RStUU1bpwMp0jm9d4,8057
86
+ bec_widgets/widgets/spiral_progress_bar/spiral_progress_bar.py,sha256=BWhkuVrHUhLWDlpNNhhFfH2cU_tIhB-nhJMH-SLiPyE,23599
87
87
  bec_widgets/widgets/toolbar/__init__.py,sha256=d-TP4_cr_VbpwreMM4ePnfZ5YXsEPQ45ibEf75nuGoE,36
88
88
  bec_widgets/widgets/toolbar/toolbar.py,sha256=e0zCD_0q7K4NVhrzD8001Qvfxt-VhqHTgofchS9NgCM,5125
89
89
  docs/Makefile,sha256=i2WHuFlgfyAPEW4ssEP8NY4cOibDJrVjvzSEU8_Ggwc,634
@@ -108,16 +108,17 @@ docs/user/customisation.md,sha256=Og0NuUsTs8HdwKtpHnycGmH8wCqOeYgj2ozlYRJ-Drk,24
108
108
  docs/user/user.md,sha256=uCTcjclIi6rdjYRQebko6bWFEVsjyfshsVU3BDYrC-Y,1403
109
109
  docs/user/api_reference/api_reference.md,sha256=q2Imc48Rq6GcAP0R4bS3KuW5ptZZdsV4wxGJb3JJQHg,174
110
110
  docs/user/applications/applications.md,sha256=yOECfaYRUEDIxF-O0duOwSJlG4f93RylrpMjbw1-8Dg,100
111
- docs/user/getting_started/command_line_introduction.md,sha256=qTGXnxyRajxv7AXbZaPVVOA5D6zBnK0M0ZF0bniymEM,8683
112
- docs/user/getting_started/getting_started.md,sha256=zYzoHC8xvHF5wDK66thkdamf8mKKNEudiA-fCOzbedM,358
111
+ docs/user/getting_started/auto_updates.md,sha256=Gicx3lplI6JRBlnPj_VL6IhqOIcsWjYF4_EdZSCje2A,3754
112
+ docs/user/getting_started/getting_started.md,sha256=lxZXCr6HAkM61oo5Bu-YjINSKo4wihWhAPJdotEAAVQ,358
113
113
  docs/user/getting_started/gui_complex_gui.gif,sha256=ovv9u371BGG5GqhzyBMl4mvqMHLfJS0ylr-dR0Ydwtw,6550393
114
114
  docs/user/getting_started/installation.md,sha256=nBl2Hfvo6ua3-tVZn1B-UG0hCTlrFY6_ibXHWnXeegs,1135
115
+ docs/user/getting_started/quick_start.md,sha256=MNXEaww5hiQY7N7AQhrmbxdYQHimFk_iKQW8tS-72cU,9337
115
116
  docs/user/widgets/bec_figure.md,sha256=Ph8ajmESk71Y9nBJsLKLiN-YvGJwN4FdN_Rs3jcObwE,5068
116
117
  docs/user/widgets/image_plot.gif,sha256=_mVFhMTXGqwDOcEtrBHMZj5Thn2sLhDAHEeL2XyHN-s,14098977
117
118
  docs/user/widgets/motor.gif,sha256=FtaWdRHx4UZaGJPpq8LNhMMgX4PFcAB6IZ93JCMEh_w,2280719
118
119
  docs/user/widgets/progress_bar.gif,sha256=5jh0Zw2BBGPuNxszV1DBLJCb4_6glIRX-U2ABjnsK2k,5263592
119
120
  docs/user/widgets/scatter_2D.gif,sha256=yHpsuAUseMafJjI_J5BcOhmE3nu9VFn_Xm9XHzJaH5I,13188862
120
- docs/user/widgets/spiral_progress_bar.md,sha256=fnkg1cRM9y49MwYVXDukHGu80SXHxsI9mU9ZfDkENPs,1114
121
+ docs/user/widgets/spiral_progress_bar.md,sha256=QTgUDIl6XPuK_HwSfB6sNijZ4bss26biDg6B_mJ8Pxk,2208
121
122
  docs/user/widgets/w1D.gif,sha256=tuHbleJpl6bJFNNC2OdndF5LF7IyfvlkFCMGZajrQPs,622773
122
123
  docs/user/widgets/widgets.md,sha256=NFdqTlLTHXueErLzvw4wHwTUrzRSEuRelb1fiT4PySg,352
123
124
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -150,7 +151,7 @@ tests/unit_tests/test_configs/config_device_no_entry.yaml,sha256=hdvue9KLc_kfNzG
150
151
  tests/unit_tests/test_configs/config_scan.yaml,sha256=vo484BbWOjA_e-h6bTjSV9k7QaQHrlAvx-z8wtY-P4E,1915
151
152
  tests/unit_tests/test_msgs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
152
153
  tests/unit_tests/test_msgs/available_scans_message.py,sha256=m_z97hIrjHXXMa2Ex-UvsPmTxOYXfjxyJaGkIY6StTY,46532
153
- bec_widgets-0.57.2.dist-info/METADATA,sha256=VKjVy_MzeMyq50c2kmwfQ9hoe6abecAZIR6nSJcwVck,1178
154
- bec_widgets-0.57.2.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
155
- bec_widgets-0.57.2.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
156
- bec_widgets-0.57.2.dist-info/RECORD,,
154
+ bec_widgets-0.57.3.dist-info/METADATA,sha256=NUwnybNOdIQRdfaJCymSOUpaYxAZhsEK9CIhk0hPz2I,1178
155
+ bec_widgets-0.57.3.dist-info/WHEEL,sha256=zEMcRr9Kr03x1ozGwg5v9NQBKn3kndp6LSoSlVg-jhU,87
156
+ bec_widgets-0.57.3.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
157
+ bec_widgets-0.57.3.dist-info/RECORD,,
@@ -0,0 +1,82 @@
1
+ (user.auto_updates)=
2
+ # Auto updates
3
+ BEC Widgets provides a simple way to update the entire GUI configuration based on events. These events can be of different types, such as a new scan being started or completed, a button being pressed, a device reporting an error or the existence of a specific metadata key. This allows the users to streamline the experience of the GUI and to focus on the data and the analysis, rather than on the GUI itself.
4
+
5
+ The default auto update only takes control over a single `BECFigure` widget, which is automatically added to the GUI instance. The update instance is accessible via the `bec.gui.auto_updates` object. The user can disable / enable the auto updates by setting the `enabled` attribute of the `bec.gui.auto_updates` object, e.g.
6
+
7
+ ```python
8
+ bec.gui.auto_updates.enabled = False
9
+ ```
10
+
11
+ Without further customization, the auto update will automatically update the `BECFigure` widget based on the currently performed scan. The behaviour is determined by the `handler` method of the `AutoUpdate` class:
12
+
13
+ ````{dropdown} Auto Updates Handler
14
+ :icon: code-square
15
+ :animate: fade-in-slide-down
16
+ :open:
17
+ ```{literalinclude} ../../../bec_widgets/cli/auto_updates.py
18
+ :pyobject: AutoUpdates.handler
19
+ ```
20
+ ````
21
+
22
+ As shown, the default handler switches between different scan names and updates the `BECFigure` widget accordingly. If the scan is a line scan, the `simple_line_scan` update method is executed.
23
+
24
+ ````{dropdown} Auto Updates Simple Line Scan
25
+ :icon: code-square
26
+ :animate: fade-in-slide-down
27
+ :open:
28
+ ```{literalinclude} ../../../bec_widgets/cli/auto_updates.py
29
+ :pyobject: AutoUpdates.simple_line_scan
30
+ ```
31
+ ````
32
+
33
+ As it can be seen from the above snippet, the update method gets the default figure by calling the `get_default_figure` method. If the figure is not found, maybe because the user has deleted or closed it, no update is performed. If the figure is found, the scan info is used to extract the first reported device for the x axis and the first device of the monitored devices for the y axis. The y axis can also be set by the user using the `selected_device` attribute:
34
+
35
+ ```python
36
+ bec.gui.auto_updates.selected_device = 'bpm4i'
37
+ ```
38
+
39
+
40
+ ````{dropdown} Auto Updates Code
41
+ :icon: code-square
42
+ :animate: fade-in-slide-down
43
+ ```{literalinclude} ../../../bec_widgets/cli/auto_updates.py
44
+ ```
45
+ ````
46
+
47
+ ## Custom Auto Updates
48
+ The beamline can customize their default behaviour through customized auto update classes. This can be achieved by modifying the class located in the beamline plugin repository: `<beamline_plugin>/bec_widgets/auto_updates.py`. The class should inherit from the `AutoUpdates` class and overwrite the `handler` method.
49
+
50
+ ```python
51
+ from bec_widgets.cli.auto_updates import AutoUpdates, ScanInfo
52
+
53
+
54
+ class PlotUpdate(AutoUpdates):
55
+ create_default_dock = True
56
+ enabled = True
57
+
58
+ # def simple_line_scan(self, info: ScanInfo) -> None:
59
+ # """
60
+ # Simple line scan.
61
+ # """
62
+ # fig = self.get_default_figure()
63
+ # if not fig:
64
+ # return
65
+ # dev_x = info.scan_report_devices[0]
66
+ # dev_y = self.get_selected_device(info.monitored_devices, self.gui.selected_device)
67
+ # if not dev_y:
68
+ # return
69
+ # fig.clear_all()
70
+ # plt = fig.plot(x_name=dev_x, y_name=dev_y)
71
+ # plt.set(title=f"Custom Plot {info.scan_number}", x_label=dev_x, y_label=dev_y)
72
+
73
+ def handler(self, info: ScanInfo) -> None:
74
+ # EXAMPLES:
75
+ # if info.scan_name == "line_scan" and info.scan_report_devices:
76
+ # self.simple_line_scan(info)
77
+ # return
78
+ # if info.scan_name == "grid_scan" and info.scan_report_devices:
79
+ # self.run_grid_scan_update(info)
80
+ # return
81
+ super().handler(info)
82
+ ```
@@ -9,5 +9,6 @@ hidden: true
9
9
  ---
10
10
 
11
11
  installation/
12
- command_line_introduction/
12
+ quick_start/
13
+ auto_updates/
13
14
  ```
@@ -1,34 +1,53 @@
1
1
  (user.command_line_introduction)=
2
- # Command Line Introduction
3
- In order to use BEC Widgets as a plotting tool for BEC, it needs to be [installed](#user.installation) in the same python environment as the BECIpythonClient. If that is the case, it will automatically launch a GUI and assign the control of the GUI to the `gui` object in the client. The GUI backend will also be automatically connect to the BEC server, giving access to all information on the server and allowing the user to visualize the data in real-time.
2
+ # Quick start
3
+ In order to use BEC Widgets as a plotting tool for BEC, it needs to be [installed](#user.installation) in the same Python environment as the BEC IPython client (please refer to the [BEC documentation](https://bec.readthedocs.io/en/latest/user/command_line_interface.html#start-up) for more details). Upon startup, the client will automatically launch a GUI and store it as a `bec.gui` object in the client. The GUI backend will also be automatically connect to the BEC server, giving access to all information on the server and allowing the user to visualize the data in real-time.
4
4
 
5
5
  ## BECDockArea
6
- The `gui` object represents the top level of hierarchy in BEC Widgets. It is a [`BECDockArea`](/api_reference/_autosummary/bec_widgets.cli.client.BECDockArea) based on the [pyqtgraph.dockarea](https://pyqtgraph.readthedocs.io/en/latest/api_reference/dockarea.html). The GUI can be further composed of multiple [`BECDock`](/api_reference/_autosummary/bec_widgets.cli.client.BECDock)s that can be detached and attached to the main area. These docks allow users to freely arrange and customize the widgets they add to the gui, giving them the necessary freedom to design the user interface they desire.
6
+ The `bec.gui` object is your entry point to BEC Widgets. It is a [`BECDockArea`](/api_reference/_autosummary/bec_widgets.cli.client.BECDockArea) instance that can be composed of multiple [`BECDock`](/api_reference/_autosummary/bec_widgets.cli.client.BECDock)s that can be attached / detached to the main area. These docks allow users to freely arrange and customize the widgets they add to the gui, providing a flexible and customizable interface to visualize data.
7
7
 
8
8
  ## Widgets
9
- Widgets are the building blocks of the BEC Widgets framework. They are the visual components that allow users to interact with the data and control the behavior of the application. Each dock can contain multiple widgets, although we recommend using a direct mapping of a single widget to a dock. We currently support two type of widgets:
10
- - [`BECFigure`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure): A widget that can be used to visualize data from BEC. It is automatically connected to the BEC server and can be used to plot data from BEC.
11
- - [`SpiralProgressBar`](/api_reference/_autosummary/bec_widgets.cli.client.SpiralProgressBar): A custom widget that can be used to show progress in a spiral shape.
9
+ Widgets are the building blocks of the BEC Widgets framework. They are the visual components that allow users to interact with the data and control the behavior of the application. Each dock can contain multiple widgets, albeit we recommend for most use cases a single widget per dock. BEC Widgets provides a set of core widgets (cf. [widgets](#user.widgets)). More widgets can be added by the users, and we invite you to explore the [developer documentation](developer.widgets) to learn how to create custom widgets.
10
+ For the introduction given here, we will focus on the `BECFigure` widget, as it is the most commonly used widget for visualizing data from BEC. The same access pattern can be used for all other widgets.
12
11
 
13
12
  **BECFigure**
14
- The [`BECFigure`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure) widget is one of the core widgets developed for BEC and designed to be flexible and can be used to visualize different types of data. It can be used to visualize [1D Waveform](user.widgets.waveform_1d), [2D Scatter Plot](user.widgets.scatter_2d), [Motor Position Map](user.widgets.motor_map) and 2D image data. As mentioned before, starting the BECIPythonClient will automatically launch a `gui` with a single dock area and a BECFigure widget attached to it. This widget is accessible via the `fig` object from the client directly. We also provide two methods [`plot()`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure.rst#bec_widgets.cli.client.BECFigure.plot), [`image()`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure.rst#bec_widgets.cli.client.BECFigure.image) and [`motor_map()`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure.rst#bec_widgets.cli.client.BECFigure.motor_map) as shortcuts to add a plot, image or motor map to the BECFigure.
13
+
14
+ The [`BECFigure`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure) widget is one of the core widgets developed for BEC and can be used to visualize different plot types, such as [1D waveforms](user.widgets.waveform_1d), [2D scatter plots](user.widgets.scatter_2d), [position maps](user.widgets.motor_map) and [2D images](user.widgets.image_2d).
15
+ If BEC Widgets is installed, the default behaviour of BEC is to automatically add a BECFigure Widget to the existing GUI instance. This widget is directly accessible via the `fig` object from the client. Moreover, a best-effort attempt is made to automatically determine the best plot type based on the currently performed scan. This behaviour can be changed or disabled by the user. For more details, please refer to the [auto update](user.auto_updates) section.
16
+
17
+ <!-- We also provide two methods [`plot()`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure.rst#bec_widgets.cli.client.BECFigure.plot), [`image()`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure.rst#bec_widgets.cli.client.BECFigure.image) and [`motor_map()`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure.rst#bec_widgets.cli.client.BECFigure.motor_map) as shortcuts to add a plot, image or motor map to the BECFigure. -->
15
18
 
16
19
  **Waveform Plot**
20
+
17
21
  The [`BECWaveForm`](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveform) is a widget that can be used to visualize 1D waveform data, i.e. to plot data of a monitor against a motor position. The method [`plot()`](/api_reference/_autosummary/bec_widgets.cli.client.BECFigure.rst#bec_widgets.cli.client.BECFigure.plot) of BECFigure adds a BECWaveForm widget to the figure, and returns the plot object.
18
22
 
19
23
  ```python
20
- plt = fig.add_plot('samx', 'bpm4i')
24
+ plt = fig.plot(x_name='samx', y_name='bpm4i')
25
+ ```
26
+ Here, we create a new plot with a subscription to the devices `samx` and `bpm4i` and assign the plot to the object `plt`. We can now use this object to further customize the plot, e.g. changing the title ([`set_title()`](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveform.rst#bec_widgets.cli.client.BECWaveform.set_title)), axis labels ([`set_x_label()`](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveform.rst#bec_widgets.cli.client.BECWaveform.set_x_label)) or limits ([`set_x_lim()`](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveform.rst#bec_widgets.cli.client.BECWaveform.set_x_lim)). We invite you to explore the API of the BECWaveForm in the [documentation](user.widgets.waveform_1d) or directly in the command line.
27
+
28
+ To plot custom data, i.e. data that is not directly available through a scan in BEC, we can use the same method, but provide the data directly to the plot.
29
+
30
+ ```python
31
+ plt = fig.plot([1,2,3,4], [1,4,9,16])
32
+ # or
33
+ plt = fig.plot(x=[1,2,3,4], y=[1,4,9,16])
34
+ # or
35
+ plt = fig.plot(x=np.array([1,2,3,4]), y=np.array([1,4,9,16]))
36
+ # or
37
+ plt = fig.plot(np.random.rand(10,2))
21
38
  ```
22
- Here, we assign the plot to the object `plt`. We can now use this object to further customize the plot, e.g. changing the title ([`set_title()`](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveform.rst#bec_widgets.cli.client.BECWaveform.set_title)), axis labels ([`set_x_label()`](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveform.rst#bec_widgets.cli.client.BECWaveform.set_x_label)) or limits ([`set_x_lim()`](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveform.rst#bec_widgets.cli.client.BECWaveform.set_x_lim)). We invite you to explore the API of the BECWaveForm in the [documentation](user.widgets.waveform_1d) or directly in the command line.
23
39
 
24
40
  **Scatter Plot**
41
+
25
42
  The [`BECWaveForm`](/api_reference/_autosummary/bec_widgets.cli.client.BECWaveForm) widget can also be used to visualize 2D scatter plots. More details on setting up the scatter plot are available in the widget documentation of the [scatter plot](user.widgets.scatter_2d).
26
43
 
27
44
  **Motor Map**
45
+
28
46
  The [`BECMotorMap`](/api_reference/_autosummary/bec_widgets.cli.client.BECMotorMap) widget can be used to visualize the position of motors. It's focused on tracking and visualizing the position of motors, crucial for precise alignment and movement tracking during scans. More details on setting up the motor map are available in the widget documentation of the [motor map](user.widgets.motor_map).
29
47
 
30
48
  **Image Plot**
31
- The [`BECImageItem`](/api_reference/_autosummary/bec_widgets.cli.client.BECImageItem) widget can be used to visualize 2D image data for example a camera. More details on setting up the image plot are available in the widget documentation of the [image plot](user.widgets.image)
49
+
50
+ The [`BECImageItem`](/api_reference/_autosummary/bec_widgets.cli.client.BECImageItem) widget can be used to visualize 2D image data for example a camera. More details on setting up the image plot are available in the widget documentation of the [image plot](user.widgets.image).
32
51
 
33
52
  ### Useful Commands
34
53
  We recommend users to explore the API of the widgets by themselves since we assume that the user interface is supposed to be intuitive and self-explanatory. We appreciate feedback from user in order to constantly improve the experience and allow easy access to the gui, widgets and their functionality. We recommend checking the [API documentation](user.api_reference), but also by using BEC Widgets, exploring the available functions and check their dockstrings.
@@ -43,32 +62,32 @@ gui.panels # returns a dictionary of all docks in the gui
43
62
  gui.add_dock() # adds a new dock to the gui
44
63
 
45
64
  dock = gui.panels['dock_2']
46
- dock.add_widget_bec('BECFigure') # adds a new widget of BECFigure to the dock
65
+ dock.add_widget('BECFigure') # adds a new widget of BECFigure to the dock
47
66
  dock.widget_list # returns a list of all widgets in the dock
48
67
 
49
68
  figure = dock.widget_list[0] # assigns the created BECFigure to figure
50
- plt = figure.add_plot('samx', 'bpm4i') # adds a BECWaveForm plot to the figure
69
+ plt = figure.plot(x_name='samx', y_name='bpm4i') # adds a BECWaveForm plot to the figure
51
70
  plt.curves # returns a list of all curves in the plot
52
71
  ```
53
72
 
54
- We note that commands can also be chained. For example, `gui.add_dock().add_widget_bec('BECFigure')` will add a new dock to the gui and add a new widget of `BECFigure` to the dock.
73
+ We note that commands can also be chained. For example, `gui.add_dock().add_widget('BECFigure')` will add a new dock to the gui and add a new widget of `BECFigure` to the dock.
55
74
 
56
75
  ## Composing a larger GUI
57
76
  The example given above introduces BEC Widgets with its different components, and provides an overview of how to interact with the widgets. Nevertheless, another power aspect of BEC Widgets lies in the ability to compose a larger GUI with multiple docks and widgets. This section aims to provide a tutorial like guide on how to compose a more complex GUI that (A) live-plots a 1D waveform, (B) plots data from a camera, and (C) tracks the positions of two motors.
58
77
  Let's assume BEC was just started and the `gui` object is available in the client. A single dock is already attached together with a BEC Figure. Let's add the 1D waveform to this dock, change the color of the line to white and add the title *1D Waveform* to the plot.
59
78
 
60
79
  ```python
61
- plt = fig.add_plot('samx', 'bpm4i')
80
+ plt = fig.plot(x_name='samx', y_name='bpm4i')
62
81
  plt.curves[0].set_color(color="white")
63
82
  plt.set_title('1D Waveform')
64
83
  ```
65
84
 
66
85
  Next, we add 2 new docks to the gui, one to plot the data of a camera and one to track the positions of two motors.
67
86
  ```ipython
68
- cam_widget= gui.add_dock(name="cam_dock").add_widget_bec('BECFigure').image("eiger")
69
- motor_widget = gui.add_dock(name="mot_dock").add_widget_bec('BECFigure').motor_map("samx", "samy")
87
+ cam_widget= gui.add_dock(name="cam_dock").add_widget('BECFigure').image("eiger")
88
+ motor_widget = gui.add_dock(name="mot_dock").add_widget('BECFigure').motor_map("samx", "samy")
70
89
  ```
71
- Note, we chain commands here which is possible since the `add_dock` and `add_widget_bec` methods return the dock and the widget respectively. We can now further customize the widgets by changing the title, axis labels, etc.
90
+ Note, we chain commands here which is possible since the `add_dock` and `add_widget` methods return the dock and the widget respectively. We can now further customize the widgets by changing the title, axis labels, etc.
72
91
 
73
92
  ```python
74
93
  cam_widget.set_title("Camera Image Eiger")
@@ -78,7 +97,7 @@ As a final step, we can now add also a SpiralProgressBar to a new dock, and perf
78
97
  As you see in the example below, all docks are arranged below each other. This is the default behavior of the `add_dock` method. However, the docks can be freely arranged by drag and drop as desired by the user. We invite you to explore this by yourself following the example in the video, and build your custom GUI with BEC Widgets.
79
98
 
80
99
  ```python
81
- prog_bar = gui.add_dock(name="prog_dock").add_widget_bec('SpiralProgressBar')
100
+ prog_bar = gui.add_dock(name="prog_dock").add_widget('SpiralProgressBar')
82
101
  prog_bar.set_line_widths(15)
83
102
  scans.grid_scan(dev.samy, -2, 2, 10, dev.samx, -5, 5, 10, exp_time=0.1, relative=False)
84
103
  ```
@@ -1,6 +1,12 @@
1
1
  (user.widgets.spiral_progress_bar)=
2
2
  # [Spiral Progress Bar](/api_reference/_autosummary/bec_widgets.cli.client.SpiralProgressBar)
3
- **Purpose** The Spiral Progress Bar widget is a circular progress bar that can be used to visualize the progress of a task. The widget is designed to be used in applications where the progress of a task is represented as a percentage. The Spiral Progress Bar widget is a part of the BEC Widgets library and can be controlled directly using its API, or hooked up to the progress of a device readback or scan.
3
+
4
+ **Purpose:**
5
+
6
+ The Spiral Progress Bar widget is a circular progress bar that can be used to visualize the progress of a task. The
7
+ widget is designed to be used in applications where the progress of a task is represented as a percentage. The Spiral
8
+ Progress Bar widget is a part of the BEC Widgets library and can be controlled directly using its API, or hooked up to
9
+ the progress of a device readback or scan.
4
10
 
5
11
  **Key Features:**
6
12
 
@@ -11,11 +17,38 @@
11
17
  **Example of Use:**
12
18
  ![SpiralProgressBar](./progress_bar.gif)
13
19
 
14
- **Code example**
15
- The following code snipped demonstrates how to create a 2D scatter plot using BEC Widgets within BEC.
20
+ **Code example:**
21
+
22
+ The following code snipped demonstrates how to create a `SpiralProgressBar` using BEC Widgets within BEC.
16
23
  ```python
17
24
  # adds a new dock with a spiral progress bar
18
25
  progress = gui.add_dock().add_widget("SpiralProgressBar")
19
26
  # customize the size of the ring
20
27
  progress.set_line_width(20)
21
- ```
28
+ ```
29
+
30
+ By default, the Spiral Progress Bar widget will display a single ring. To add more rings, use the add_ring method:
31
+
32
+ ```python
33
+ # adds a new dock with a spiral progress bar
34
+ progress.add_ring()
35
+ ```
36
+
37
+ To access rings and specify their properties, you can use `progress.rings` with an index specifying the ring index (
38
+ starting from 0):
39
+
40
+ ```python
41
+ progress.rings[0].set_line_width(20) # set the width of the first ring
42
+ progress.rings[1].set_line_width(10) # set the width of the second ring
43
+ ```
44
+
45
+ By default, the `SpiralProgressBar` widget is set with `progress.enable_auto_update(True)`, which will automatically
46
+ update the bars in the widget. To manually set updates for each progress bar, use the set_update method. Note that
47
+ manually updating a ring will disable the automatic update for the whole widget:
48
+
49
+ ```python
50
+ progress.rings[0].set_update("scan") # set the update of the first ring to be an overall scan progress
51
+ progress.rings[1].set_update("device",
52
+ "samx") # set the update of the second ring to be a device readback (in this case, samx)
53
+ ```
54
+
pyproject.toml CHANGED
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "bec_widgets"
7
- version = "0.57.2"
7
+ version = "0.57.3"
8
8
  description = "BEC Widgets"
9
9
  requires-python = ">=3.10"
10
10
  classifiers = [