bec-widgets 0.83.0__py3-none-any.whl → 0.84.0__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 (30) hide show
  1. CHANGELOG.md +50 -54
  2. PKG-INFO +2 -2
  3. bec_widgets/cli/client.py +61 -8
  4. bec_widgets/examples/jupyter_console/jupyter_console_window.py +107 -59
  5. bec_widgets/qt_utils/toolbar.py +3 -1
  6. bec_widgets/utils/bec_dispatcher.py +5 -2
  7. bec_widgets/utils/colors.py +27 -0
  8. bec_widgets/widgets/bec_status_box/bec_status_box.py +2 -2
  9. bec_widgets/widgets/device_box/device_box.py +2 -2
  10. bec_widgets/widgets/figure/figure.py +23 -117
  11. bec_widgets/widgets/figure/plots/axis_settings.py +2 -2
  12. bec_widgets/widgets/figure/plots/waveform/waveform.py +651 -94
  13. bec_widgets/widgets/figure/plots/waveform/waveform_curve.py +9 -2
  14. bec_widgets/widgets/scan_control/scan_control.py +2 -2
  15. bec_widgets/widgets/spinner/spinner.py +4 -3
  16. {bec_widgets-0.83.0.dist-info → bec_widgets-0.84.0.dist-info}/METADATA +2 -2
  17. {bec_widgets-0.83.0.dist-info → bec_widgets-0.84.0.dist-info}/RECORD +29 -30
  18. pyproject.toml +2 -2
  19. tests/references/SpinnerWidget/SpinnerWidget_darwin.png +0 -0
  20. tests/references/SpinnerWidget/SpinnerWidget_linux.png +0 -0
  21. tests/references/SpinnerWidget/SpinnerWidget_started_darwin.png +0 -0
  22. tests/references/SpinnerWidget/SpinnerWidget_started_linux.png +0 -0
  23. tests/unit_tests/client_mocks.py +13 -4
  24. tests/unit_tests/test_device_input_widgets.py +2 -0
  25. tests/unit_tests/test_spinner.py +2 -2
  26. tests/unit_tests/test_waveform1d.py +202 -23
  27. bec_widgets/examples/jupyter_console/jupyter_console_window.ui +0 -54
  28. {bec_widgets-0.83.0.dist-info → bec_widgets-0.84.0.dist-info}/WHEEL +0 -0
  29. {bec_widgets-0.83.0.dist-info → bec_widgets-0.84.0.dist-info}/entry_points.txt +0 -0
  30. {bec_widgets-0.83.0.dist-info → bec_widgets-0.84.0.dist-info}/licenses/LICENSE +0 -0
@@ -7,13 +7,13 @@ from typing import Literal, Optional
7
7
 
8
8
  import numpy as np
9
9
  import pyqtgraph as pg
10
- import qdarktheme
11
10
  from pydantic import Field, ValidationError, field_validator
12
11
  from qtpy.QtCore import Signal as pyqtSignal
13
12
  from qtpy.QtWidgets import QWidget
14
13
  from typeguard import typechecked
15
14
 
16
15
  from bec_widgets.utils import BECConnector, ConnectionConfig, WidgetContainerUtils
16
+ from bec_widgets.utils.colors import apply_theme
17
17
  from bec_widgets.widgets.figure.plots.image.image import BECImageShow, ImageConfig
18
18
  from bec_widgets.widgets.figure.plots.motor_map.motor_map import BECMotorMap, MotorMapConfig
19
19
  from bec_widgets.widgets.figure.plots.plot_base import BECPlotBase, SubplotConfig
@@ -227,106 +227,12 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
227
227
  """
228
228
  self._widgets = value
229
229
 
230
- def _init_waveform(
231
- self,
232
- waveform,
233
- x_name: str = None,
234
- y_name: str = None,
235
- z_name: str = None,
236
- x_entry: str = None,
237
- y_entry: str = None,
238
- z_entry: str = None,
239
- x: list | np.ndarray = None,
240
- y: list | np.ndarray = None,
241
- color: str | None = None,
242
- color_map_z: str | None = "plasma",
243
- label: str | None = None,
244
- validate: bool = True,
245
- dap: str | None = None,
246
- ) -> BECWaveform:
247
- """
248
- Configure the waveform based on the provided parameters.
249
-
250
- Args:
251
- waveform (BECWaveform): The waveform to configure.
252
- x (list | np.ndarray): Custom x data to plot.
253
- y (list | np.ndarray): Custom y data to plot.
254
- x_name (str): The name of the device for the x-axis.
255
- y_name (str): The name of the device for the y-axis.
256
- z_name (str): The name of the device for the z-axis.
257
- x_entry (str): The name of the entry for the x-axis.
258
- y_entry (str): The name of the entry for the y-axis.
259
- z_entry (str): The name of the entry for the z-axis.
260
- color (str): The color of the curve.
261
- color_map_z (str): The color map to use for the z-axis.
262
- label (str): The label of the curve.
263
- validate (bool): If True, validate the device names and entries.
264
- dap (str): The DAP model to use for the curve.
265
- """
266
- if x is not None and y is None:
267
- if isinstance(x, np.ndarray):
268
- if x.ndim == 1:
269
- y = np.arange(x.size)
270
- waveform.add_curve_custom(x=np.arange(x.size), y=x, color=color, label=label)
271
- return waveform
272
- if x.ndim == 2:
273
- waveform.add_curve_custom(x=x[:, 0], y=x[:, 1], color=color, label=label)
274
- return waveform
275
- elif isinstance(x, list):
276
- y = np.arange(len(x))
277
- waveform.add_curve_custom(x=np.arange(len(x)), y=x, color=color, label=label)
278
- return waveform
279
- else:
280
- raise ValueError(
281
- "Invalid input. Provide either device names (x_name, y_name) or custom data."
282
- )
283
- if x is not None and y is not None:
284
- waveform.add_curve_custom(x=x, y=y, color=color, label=label)
285
- return waveform
286
- # User wants to add scan curve -> 1D Waveform
287
- if x_name is not None and y_name is not None and z_name is None and x is None and y is None:
288
- waveform.plot(
289
- x_name=x_name,
290
- y_name=y_name,
291
- x_entry=x_entry,
292
- y_entry=y_entry,
293
- validate=validate,
294
- color=color,
295
- label=label,
296
- dap=dap,
297
- )
298
- # User wants to add scan curve -> 2D Waveform Scatter
299
- if (
300
- x_name is not None
301
- and y_name is not None
302
- and z_name is not None
303
- and x is None
304
- and y is None
305
- ):
306
- waveform.plot(
307
- x_name=x_name,
308
- y_name=y_name,
309
- z_name=z_name,
310
- x_entry=x_entry,
311
- y_entry=y_entry,
312
- z_entry=z_entry,
313
- color=color,
314
- color_map_z=color_map_z,
315
- label=label,
316
- validate=validate,
317
- dap=dap,
318
- )
319
- # User wants to add custom curve
320
- elif x is not None and y is not None and x_name is None and y_name is None:
321
- waveform.add_curve_custom(x=x, y=y, color=color, label=label)
322
-
323
- return waveform
324
-
325
230
  @typechecked
326
231
  def plot(
327
232
  self,
328
- x: list | np.ndarray | None = None,
233
+ arg1: list | np.ndarray | str | None = None,
329
234
  y: list | np.ndarray | None = None,
235
+ x: list | np.ndarray | None = None,
330
236
  x_name: str | None = None,
331
237
  y_name: str | None = None,
332
238
  z_name: str | None = None,
@@ -348,8 +254,9 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
348
254
  Add a 1D waveform plot to the figure. Always access the first waveform widget in the figure.
349
255
 
350
256
  Args:
351
- x(list | np.ndarray): Custom x data to plot.
257
+ arg1(list | np.ndarray | str | None): First argument which can be x data, y data, or y_name.
352
258
  y(list | np.ndarray): Custom y data to plot.
259
+ x(list | np.ndarray): Custom x data to plot.
353
260
  x_name(str): The name of the device for the x-axis.
354
261
  y_name(str): The name of the device for the y-axis.
355
262
  z_name(str): The name of the device for the z-axis.
@@ -376,23 +283,23 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
376
283
  if config is not None:
377
284
  return waveform
378
285
 
379
- # Passing args to init_waveform
380
- waveform = self._init_waveform(
381
- waveform=waveform,
382
- x=x,
383
- y=y,
384
- x_name=x_name,
385
- y_name=y_name,
386
- z_name=z_name,
387
- x_entry=x_entry,
388
- y_entry=y_entry,
389
- z_entry=z_entry,
390
- color=color,
391
- color_map_z=color_map_z,
392
- label=label,
393
- validate=validate,
394
- dap=dap,
395
- )
286
+ if arg1 is not None or y_name is not None or (y is not None and x is not None):
287
+ waveform.plot(
288
+ arg1=arg1,
289
+ y=y,
290
+ x=x,
291
+ x_name=x_name,
292
+ y_name=y_name,
293
+ z_name=z_name,
294
+ x_entry=x_entry,
295
+ y_entry=y_entry,
296
+ z_entry=z_entry,
297
+ color=color,
298
+ color_map_z=color_map_z,
299
+ label=label,
300
+ validate=validate,
301
+ dap=dap,
302
+ )
396
303
  return waveform
397
304
 
398
305
  def _init_image(
@@ -670,9 +577,8 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
670
577
  Args:
671
578
  theme(Literal["dark","light"]): The theme to set for the figure widget.
672
579
  """
673
- qdarktheme.setup_theme(theme)
674
- self.setBackground("k" if theme == "dark" else "w")
675
580
  self.config.theme = theme
581
+ apply_theme(theme)
676
582
  for plot in self.widget_list:
677
583
  plot.set_x_label(plot.plot_item.getAxis("bottom").label.toPlainText())
678
584
  plot.set_y_label(plot.plot_item.getAxis("left").label.toPlainText())
@@ -1,10 +1,10 @@
1
1
  import os
2
2
 
3
- import qdarktheme
4
3
  from qtpy.QtCore import Slot
5
4
  from qtpy.QtWidgets import QVBoxLayout, QWidget
6
5
 
7
6
  from bec_widgets.utils import UILoader
7
+ from bec_widgets.utils.colors import apply_theme
8
8
  from bec_widgets.utils.widget_io import WidgetIO
9
9
 
10
10
 
@@ -55,7 +55,7 @@ if __name__ == "__main__":
55
55
  from qtpy.QtWidgets import QApplication
56
56
 
57
57
  app = QApplication(sys.argv)
58
- qdarktheme.setup_theme("dark")
58
+ apply_theme("dark")
59
59
  window = AxisSettings()
60
60
  window.show()
61
61
  sys.exit(app.exec_())