bec-widgets 0.52.0__py3-none-any.whl → 0.52.1__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.
@@ -281,6 +281,7 @@ class RPCBase:
281
281
  def _wait_for_response(self, request_id: str, timeout: int = 5):
282
282
  """
283
283
  Wait for the response from the server.
284
+
284
285
  Args:
285
286
  request_id(str): The request ID.
286
287
  timeout(int): The timeout in seconds.
@@ -41,6 +41,7 @@ from typing import Literal, Optional, overload"""
41
41
  def generate_content_for_class(self, cls):
42
42
  """
43
43
  Generate the content for the class.
44
+
44
45
  Args:
45
46
  cls: The class for which to generate the content.
46
47
  """
@@ -28,6 +28,7 @@ class RPCRegister:
28
28
  def add_rpc(self, rpc: QObject):
29
29
  """
30
30
  Add an RPC object to the register.
31
+
31
32
  Args:
32
33
  rpc(QObject): The RPC object to be added to the register.
33
34
  """
@@ -38,6 +39,7 @@ class RPCRegister:
38
39
  def remove_rpc(self, rpc: str):
39
40
  """
40
41
  Remove an RPC object from the register.
42
+
41
43
  Args:
42
44
  rpc(str): The RPC object to be removed from the register.
43
45
  """
@@ -48,6 +50,7 @@ class RPCRegister:
48
50
  def get_rpc_by_id(self, gui_id: str) -> QObject:
49
51
  """
50
52
  Get an RPC object by its ID.
53
+
51
54
  Args:
52
55
  gui_id(str): The ID of the RPC object to be retrieved.
53
56
 
@@ -60,6 +63,7 @@ class RPCRegister:
60
63
  def list_all_connections(self) -> dict:
61
64
  """
62
65
  List all the registered RPC objects.
66
+
63
67
  Returns:
64
68
  dict: A dictionary containing all the registered RPC objects.
65
69
  """
@@ -13,6 +13,7 @@ class RPCWidgetHandler:
13
13
  def create_widget(widget_type, **kwargs) -> BECConnector:
14
14
  """
15
15
  Create a widget from an RPC message.
16
+
16
17
  Args:
17
18
  widget_type(str): The type of the widget.
18
19
  **kwargs: The keyword arguments for the widget.
@@ -78,6 +78,7 @@ class BECConnector:
78
78
  def config_dict(self) -> dict:
79
79
  """
80
80
  Get the configuration of the widget.
81
+
81
82
  Returns:
82
83
  dict: The configuration of the widget.
83
84
  """
@@ -87,6 +88,7 @@ class BECConnector:
87
88
  def config_dict(self, config: BaseModel) -> None:
88
89
  """
89
90
  Get the configuration of the widget.
91
+
90
92
  Returns:
91
93
  dict: The configuration of the widget.
92
94
  """
@@ -96,6 +98,7 @@ class BECConnector:
96
98
  def set_gui_id(self, gui_id: str) -> None:
97
99
  """
98
100
  Set the GUI ID for the widget.
101
+
99
102
  Args:
100
103
  gui_id(str): GUI ID
101
104
  """
@@ -116,6 +119,7 @@ class BECConnector:
116
119
 
117
120
  def update_client(self, client) -> None:
118
121
  """Update the client and device manager from BEC and create object for BEC shortcuts.
122
+
119
123
  Args:
120
124
  client: BEC client
121
125
  """
@@ -126,6 +130,7 @@ class BECConnector:
126
130
  def on_config_update(self, config: ConnectionConfig | dict) -> None:
127
131
  """
128
132
  Update the configuration for the widget.
133
+
129
134
  Args:
130
135
  config(ConnectionConfig): Configuration settings.
131
136
  """
@@ -138,8 +143,10 @@ class BECConnector:
138
143
  def get_config(self, dict_output: bool = True) -> dict | BaseModel:
139
144
  """
140
145
  Get the configuration of the widget.
146
+
141
147
  Args:
142
148
  dict_output(bool): If True, return the configuration as a dictionary. If False, return the configuration as a pydantic model.
149
+
143
150
  Returns:
144
151
  dict: The configuration of the plot widget.
145
152
  """
@@ -8,6 +8,7 @@ class BECTable(QTableWidget):
8
8
  def keyPressEvent(self, event) -> None:
9
9
  """
10
10
  Delete selected rows with backspace or delete key
11
+
11
12
  Args:
12
13
  event: keyPressEvent
13
14
  """
@@ -10,6 +10,7 @@ class WidgetContainerUtils:
10
10
  def generate_unique_widget_id(container: dict, prefix: str = "widget") -> str:
11
11
  """
12
12
  Generate a unique widget ID.
13
+
13
14
  Args:
14
15
  container(dict): The container of widgets.
15
16
  prefix(str): The prefix of the widget ID.
@@ -29,10 +30,12 @@ class WidgetContainerUtils:
29
30
  ) -> QWidget | None:
30
31
  """
31
32
  Find the first widget of a given class in the figure.
33
+
32
34
  Args:
33
35
  container(dict): The container of widgets.
34
36
  widget_class(Type): The class of the widget to find.
35
37
  can_fail(bool): If True, the method will return None if no widget is found. If False, it will raise an error.
38
+
36
39
  Returns:
37
40
  widget: The widget of the given class.
38
41
  """
@@ -17,6 +17,7 @@ class Crosshair(QObject):
17
17
  def __init__(self, plot_item: pg.PlotItem, precision: int = None, parent=None):
18
18
  """
19
19
  Crosshair for 1D and 2D plots.
20
+
20
21
  Args:
21
22
  plot_item (pyqtgraph.PlotItem): The plot item to which the crosshair will be attached.
22
23
  precision (int, optional): Number of decimal places to round the coordinates to. Defaults to None.
@@ -5,6 +5,7 @@ class EntryValidator:
5
5
  def validate_signal(self, name: str, entry: str = None) -> str:
6
6
  """
7
7
  Validate a signal entry for a given device. If the entry is not provided, the first signal entry will be used from the device hints.
8
+
8
9
  Args:
9
10
  name(str): Device name
10
11
  entry(str): Signal entry
@@ -28,6 +29,7 @@ class EntryValidator:
28
29
  def validate_monitor(self, monitor: str) -> str:
29
30
  """
30
31
  Validate a monitor entry for a given device.
32
+
31
33
  Args:
32
34
  monitor(str): Monitor entry
33
35
 
@@ -21,6 +21,7 @@ class GridLayoutManager:
21
21
  def is_position_occupied(self, row: int, col: int) -> bool:
22
22
  """
23
23
  Check if the position in the layout is occupied by a widget.
24
+
24
25
  Args:
25
26
  row(int): The row to check.
26
27
  col(int): The column to check.
@@ -42,6 +43,7 @@ class GridLayoutManager:
42
43
  ):
43
44
  """
44
45
  Shift widgets in the layout in the specified direction starting from the specified position.
46
+
45
47
  Args:
46
48
  direction(str): The direction to shift the widgets. Can be "down", "up", "left", or "right".
47
49
  start_row(int): The row to start shifting from. Default is 0.
@@ -63,6 +65,7 @@ class GridLayoutManager:
63
65
  def move_widget(self, widget: QWidget, new_row: int, new_col: int):
64
66
  """
65
67
  Move a widget to a new position in the layout.
68
+
66
69
  Args:
67
70
  widget(QWidget): The widget to move.
68
71
  new_row(int): The new row to move the widget to.
@@ -82,6 +85,7 @@ class GridLayoutManager:
82
85
  ):
83
86
  """
84
87
  Add a widget to the layout at the specified position.
88
+
85
89
  Args:
86
90
  widget(QWidget): The widget to add.
87
91
  row(int): The row to add the widget to. If None, the widget will be added to the next available row.
@@ -114,6 +114,7 @@ class WidgetIO:
114
114
  def get_value(widget, ignore_errors=False):
115
115
  """
116
116
  Retrieve value from the widget instance.
117
+
117
118
  Args:
118
119
  widget: Widget instance.
119
120
  ignore_errors(bool, optional): Whether to ignore if no handler is found.
@@ -129,6 +130,7 @@ class WidgetIO:
129
130
  def set_value(widget, value, ignore_errors=False):
130
131
  """
131
132
  Set a value on the widget instance.
133
+
132
134
  Args:
133
135
  widget: Widget instance.
134
136
  value: Value to set.
@@ -155,6 +157,7 @@ class WidgetHierarchy:
155
157
  ) -> None:
156
158
  """
157
159
  Print the widget hierarchy to the console.
160
+
158
161
  Args:
159
162
  widget: Widget to print the hierarchy of
160
163
  indent(int, optional): Level of indentation.
@@ -196,6 +199,7 @@ class WidgetHierarchy:
196
199
  ) -> dict:
197
200
  """
198
201
  Export the widget hierarchy to a dictionary.
202
+
199
203
  Args:
200
204
  widget: Widget to print the hierarchy of.
201
205
  config(dict,optional): Dictionary to export the hierarchy to.
@@ -245,6 +249,7 @@ class WidgetHierarchy:
245
249
  def import_config_from_dict(widget, config: dict, set_values: bool = False) -> None:
246
250
  """
247
251
  Import the widget hierarchy from a dictionary.
252
+
248
253
  Args:
249
254
  widget: Widget to import the hierarchy to.
250
255
  config:
@@ -9,6 +9,7 @@ from qtpy.QtWidgets import QFileDialog
9
9
  def load_yaml(instance) -> Union[dict, None]:
10
10
  """
11
11
  Load YAML file from disk.
12
+
12
13
  Args:
13
14
  instance: Instance of the calling widget.
14
15
 
@@ -40,6 +41,7 @@ def load_yaml(instance) -> Union[dict, None]:
40
41
  def save_yaml(instance, config: dict) -> None:
41
42
  """
42
43
  Save YAML file to disk.
44
+
43
45
  Args:
44
46
  instance: Instance of the calling widget.
45
47
  config: Configuration data to be saved.
@@ -8,7 +8,7 @@ class Signal(BaseModel):
8
8
  """
9
9
  Represents a signal in a plot configuration.
10
10
 
11
- Attributes:
11
+ Args:
12
12
  name (str): The name of the signal.
13
13
  entry (Optional[str]): The entry point of the signal, optional.
14
14
  """
@@ -21,6 +21,7 @@ class Signal(BaseModel):
21
21
  def validate_fields(cls, values):
22
22
  """Validate the fields of the model.
23
23
  First validate the 'name' field, then validate the 'entry' field.
24
+
24
25
  Args:
25
26
  values (dict): The values to be validated."""
26
27
  devices = MonitorConfigValidator.devices
@@ -77,6 +77,7 @@ class BECDockArea(BECConnector, DockArea):
77
77
  ):
78
78
  """
79
79
  Restore the state of the dock area. If no state is provided, the last state is restored.
80
+
80
81
  Args:
81
82
  state(dict): The state to restore.
82
83
  missing(Literal['ignore','error']): What to do if a dock is missing.
@@ -89,6 +90,7 @@ class BECDockArea(BECConnector, DockArea):
89
90
  def save_state(self) -> dict:
90
91
  """
91
92
  Save the state of the dock area.
93
+
92
94
  Returns:
93
95
  dict: The state of the dock area.
94
96
  """
@@ -98,6 +100,7 @@ class BECDockArea(BECConnector, DockArea):
98
100
  def remove_dock(self, name: str):
99
101
  """
100
102
  Remove a dock by name and ensure it is properly closed and cleaned up.
103
+
101
104
  Args:
102
105
  name(str): The name of the dock to remove.
103
106
  """
@@ -138,6 +141,7 @@ class BECDockArea(BECConnector, DockArea):
138
141
  col(int): The column of the added widget.
139
142
  rowspan(int): The rowspan of the added widget.
140
143
  colspan(int): The colspan of the added widget.
144
+
141
145
  Returns:
142
146
  BECDock: The created dock.
143
147
  """
@@ -178,6 +182,7 @@ class BECDockArea(BECConnector, DockArea):
178
182
  def detach_dock(self, dock_name: str) -> BECDock:
179
183
  """
180
184
  Undock a dock from the dock area.
185
+
181
186
  Args:
182
187
  dock_name(str): The dock to undock.
183
188
 
@@ -210,6 +210,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
210
210
  ) -> BECWaveform:
211
211
  """
212
212
  Add a Waveform1D plot to the figure at the specified position.
213
+
213
214
  Args:
214
215
  widget_id(str): The unique identifier of the widget. If not provided, a unique ID will be generated.
215
216
  row(int): The row coordinate of the widget in the figure. If not provided, the next empty row will be used.
@@ -289,6 +290,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
289
290
  ) -> BECWaveform:
290
291
  """
291
292
  Add a 1D waveform plot to the figure. Always access the first waveform widget in the figure.
293
+
292
294
  Args:
293
295
  x_name(str): The name of the device for the x-axis.
294
296
  y_name(str): The name of the device for the y-axis.
@@ -375,6 +377,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
375
377
  ) -> BECImageShow:
376
378
  """
377
379
  Add an image to the figure. Always access the first image widget in the figure.
380
+
378
381
  Args:
379
382
  monitor(str): The name of the monitor to display.
380
383
  color_bar(Literal["simple","full"]): The type of color bar to display.
@@ -428,6 +431,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
428
431
  ) -> BECImageShow:
429
432
  """
430
433
  Add an image to the figure at the specified position.
434
+
431
435
  Args:
432
436
  monitor(str): The name of the monitor to display.
433
437
  color_bar(Literal["simple","full"]): The type of color bar to display.
@@ -482,6 +486,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
482
486
  def motor_map(self, motor_x: str = None, motor_y: str = None, **axis_kwargs) -> BECMotorMap:
483
487
  """
484
488
  Add a motor map to the figure. Always access the first motor map widget in the figure.
489
+
485
490
  Args:
486
491
  motor_x(str): The name of the motor for the X axis.
487
492
  motor_y(str): The name of the motor for the Y axis.
@@ -558,6 +563,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
558
563
  ) -> BECPlotBase:
559
564
  """
560
565
  Add a widget to the figure at the specified position.
566
+
561
567
  Args:
562
568
  widget_type(Literal["PlotBase","Waveform1D"]): The type of the widget to add.
563
569
  widget_id(str): The unique identifier of the widget. If not provided, a unique ID will be generated.
@@ -620,6 +626,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
620
626
  ) -> None:
621
627
  """
622
628
  Remove a widget from the figure. Can be removed by its unique identifier or by its coordinates.
629
+
623
630
  Args:
624
631
  row(int): The row coordinate of the widget to remove.
625
632
  col(int): The column coordinate of the widget to remove.
@@ -638,6 +645,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
638
645
  def change_theme(self, theme: Literal["dark", "light"]) -> None:
639
646
  """
640
647
  Change the theme of the figure widget.
648
+
641
649
  Args:
642
650
  theme(Literal["dark","light"]): The theme to set for the figure widget.
643
651
  """
@@ -648,6 +656,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
648
656
  def _remove_by_coordinates(self, row: int, col: int) -> None:
649
657
  """
650
658
  Remove a widget from the figure by its coordinates.
659
+
651
660
  Args:
652
661
  row(int): The row coordinate of the widget to remove.
653
662
  col(int): The column coordinate of the widget to remove.
@@ -661,6 +670,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
661
670
  def _remove_by_id(self, widget_id: str) -> None:
662
671
  """
663
672
  Remove a widget from the figure by its unique identifier.
673
+
664
674
  Args:
665
675
  widget_id(str): The unique identifier of the widget to remove.
666
676
  """
@@ -678,6 +688,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
678
688
  def axes(self, row: int, col: int) -> BECPlotBase:
679
689
  """
680
690
  Get widget by its coordinates in the figure.
691
+
681
692
  Args:
682
693
  row(int): the row coordinate
683
694
  col(int): the column coordinate
@@ -700,6 +711,7 @@ class BECFigure(BECConnector, pg.GraphicsLayoutWidget):
700
711
  def _change_grid(self, widget_id: str, row: int, col: int):
701
712
  """
702
713
  Change the grid to reflect the new position of the widget.
714
+
703
715
  Args:
704
716
  widget_id(str): The unique identifier of the widget.
705
717
  row(int): The new row coordinate of the widget in the figure.