bec-widgets 0.117.1__py3-none-any.whl → 0.119.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 (26) hide show
  1. CHANGELOG.md +47 -51
  2. PKG-INFO +1 -1
  3. bec_widgets/applications/alignment/alignment_1d/alignment_1d.py +33 -89
  4. bec_widgets/applications/alignment/alignment_1d/alignment_1d.ui +413 -715
  5. bec_widgets/examples/jupyter_console/jupyter_console_window.py +1 -1
  6. bec_widgets/qt_utils/compact_popup.py +68 -23
  7. bec_widgets/qt_utils/toolbar.py +51 -12
  8. bec_widgets/widgets/device_line_edit/device_line_edit.py +15 -1
  9. bec_widgets/widgets/figure/figure.py +10 -1
  10. bec_widgets/widgets/figure/plots/image/image.py +86 -19
  11. bec_widgets/widgets/image/image_widget.py +15 -2
  12. bec_widgets/widgets/positioner_box/positioner_box.py +10 -4
  13. bec_widgets/widgets/positioner_group/__init__.py +0 -0
  14. bec_widgets/widgets/positioner_group/positioner_group.py +170 -0
  15. bec_widgets/widgets/positioner_group/positioner_group.pyproject +1 -0
  16. bec_widgets/widgets/positioner_group/positioner_group_plugin.py +57 -0
  17. bec_widgets/widgets/positioner_group/register_positioner_group.py +15 -0
  18. bec_widgets/widgets/scan_control/scan_control.py +74 -122
  19. bec_widgets/widgets/scan_control/scan_group_box.py +66 -11
  20. bec_widgets/widgets/stop_button/stop_button.py +1 -1
  21. {bec_widgets-0.117.1.dist-info → bec_widgets-0.119.0.dist-info}/METADATA +1 -1
  22. {bec_widgets-0.117.1.dist-info → bec_widgets-0.119.0.dist-info}/RECORD +26 -21
  23. pyproject.toml +1 -1
  24. {bec_widgets-0.117.1.dist-info → bec_widgets-0.119.0.dist-info}/WHEEL +0 -0
  25. {bec_widgets-0.117.1.dist-info → bec_widgets-0.119.0.dist-info}/entry_points.txt +0 -0
  26. {bec_widgets-0.117.1.dist-info → bec_widgets-0.119.0.dist-info}/licenses/LICENSE +0 -0
CHANGELOG.md CHANGED
@@ -1,6 +1,53 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v0.119.0 (2024-10-17)
5
+
6
+ ### Features
7
+
8
+ * feat: new PositionerGroup widget ([`af9655d`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/af9655de0c541092437accfbaa779628a2f48ccb))
9
+
10
+ * feat: add 'expand_popup' property to CompactPopupWidget
11
+
12
+ This property tells if expand should show a popup (by default), or
13
+ if the widget should expand in-place ([`e4121a0`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/e4121a01cb6b8d496e630cd43bc642b994b8f310))
14
+
15
+ * feat: PositionerBox with a popup view ([`2615787`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/261578796f1de8ca9cab9b91659bc1484f7aa89d))
16
+
17
+ * feat: emit 'device_selected' and 'scan_axis' from scan control widget ([`0b9b1a3`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/0b9b1a3c89a98505079f7d4078915b7bbfaa1e23))
18
+
19
+ * feat: new 'device_selected' signals to ScanControl, ScanGroupBox, DeviceLineEdit ([`9801d27`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/9801d2769eb0ee95c94ec0c011e1dac1407142ae))
20
+
21
+ ### Fixes
22
+
23
+ * fix: fix syntax due to change of api for simulated devices ([`19f4e40`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/19f4e407e00ee242973ca4c3f90e4e41a4d3e315))
24
+
25
+ * fix: remove wrongly scoped test ([`a23841b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/a23841b2553dc7162da943715d58275c7dc39ed9))
26
+
27
+ * fix: rename 'compact' property -> 'compact_view' ([`6982711`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/6982711fea5fb8a73845ed7c0692e3ec53ef7871))
28
+
29
+ * fix: Alignment 1D update, make app window a main window (in .ui file) ([`0015f0e`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/0015f0e2d62adc02d3ef334e1f6dbb2d0288fec6))
30
+
31
+ * fix: set (Minimum, Fixed) size policy on Stop button ([`523cc43`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/523cc435725b10b7d59a4477a1aaa24a1f3e37a2))
32
+
33
+ ### Refactoring
34
+
35
+ * refactor: redesign of scan selection and scan control boxes ([`a69d287`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/a69d2870e2b3539739781d741b27b8599c0f4abd))
36
+
37
+ * refactor: move add/remove bundle to scan group box ([`e3d0a7b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/e3d0a7bbf9918dc16eb7227a178c310256ce570d))
38
+
39
+
40
+ ## v0.118.0 (2024-10-13)
41
+
42
+ ### Documentation
43
+
44
+ * docs(sphinx-build): adjusted pyside verion ([`b236951`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/b23695167ab969f754a058ffdccca2b40f00a008))
45
+
46
+ ### Features
47
+
48
+ * feat(image): image widget can take data from monitor_1d endpoint ([`9ef1d1c`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/9ef1d1c9ac2178d9fa2e655942208f8abbdf5c1b))
49
+
50
+
4
51
  ## v0.117.1 (2024-10-11)
5
52
 
6
53
  ### Fixes
@@ -118,57 +165,6 @@ Fixes #361, do not try to change x axis when not permitted ([`efa2763`](https://
118
165
 
119
166
  * docs(dap_combo_box): updated screenshot ([`e3b5e33`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/e3b5e338bfaec276979183fb6d79ab41a7ca21e1))
120
167
 
121
- * docs(device_box): updated screenshot ([`c8e614b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c8e614b575b48be788a6389a7aa0cfa033d86ab8))
122
-
123
168
  ### Fixes
124
169
 
125
170
  * fix: test e2e dap wait_for_fit ([`b2f7d3c`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/b2f7d3c5f3f4bf00cc628f788e2c278ebb5688ae))
126
-
127
-
128
- ## v0.112.0 (2024-09-17)
129
-
130
- ### Features
131
-
132
- * feat: console: various improvements, auto-adapt rows to widget size, Qt Designer plugin ([`286ad71`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/286ad7196b0b8562d648fb304eab7d759b6a959b))
133
-
134
-
135
- ## v0.111.0 (2024-09-17)
136
-
137
- ### Documentation
138
-
139
- * docs(position_indicator): updated position indicator documentation and added designer properties ([`60f7d54`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/60f7d54e2b4c3129de6c95729b8b4aea1757174f))
140
-
141
- ### Features
142
-
143
- * feat(position_indicator): improved design and added more customization options ([`d15b222`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/d15b22250fbceb708d89872c0380693e04acb107))
144
-
145
- ### Fixes
146
-
147
- * fix(position_indicator): fixed user access ([`dd932dd`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/dd932dd8f3910ab67ec8403124f4e176d048e542))
148
-
149
- * fix(generate_cli): fixed type annotations ([`d3c1a1b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/d3c1a1b2edcba7afea9d369820fa7974ac29c333))
150
-
151
- * fix(positioner_box): visual improvements to the positioner_box and positioner_control_line ([`7ea4a48`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/7ea4a482e7cd9499a7268ac887b345cab01632aa))
152
-
153
- * fix(palette viewer): fixed background for tool tip ([`9045323`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/9045323049d2a39c36fc8845f3b2883d6933436b))
154
-
155
-
156
- ## v0.110.0 (2024-09-12)
157
-
158
- ### Features
159
-
160
- * feat(palette_viewer): added widget to display the current palette and accent colors ([`a8576c1`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/a8576c164cad17746ec4fcd5c775fb78f70c055c))
161
-
162
-
163
- ## v0.109.1 (2024-09-09)
164
-
165
- ### Fixes
166
-
167
- * fix: refactor textbox widget, remove inheritance, adhere to bec style; closes #324 ([`b0d786b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/b0d786b991677c0846a0c6ba3f2252d48d94ccaa))
168
-
169
-
170
- ## v0.109.0 (2024-09-06)
171
-
172
- ### Features
173
-
174
- * feat(accent colors): added helper function to get all accent colors ([`84a59f7`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/84a59f70eed6d8a3c3aeeabc77a5f9ea4e864f61))
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.117.1
3
+ Version: 0.119.0
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
@@ -8,45 +8,54 @@ from typing import Optional
8
8
  from bec_lib.device import Positioner as BECPositioner
9
9
  from bec_lib.device import Signal as BECSignal
10
10
  from bec_lib.endpoints import MessageEndpoints
11
+ from bec_lib.logger import bec_logger
11
12
  from qtpy.QtCore import QSize, Signal
12
13
  from qtpy.QtGui import QIcon
13
- from qtpy.QtWidgets import QCheckBox, QDoubleSpinBox, QMainWindow, QPushButton, QSpinBox
14
+ from qtpy.QtWidgets import (
15
+ QApplication,
16
+ QCheckBox,
17
+ QDoubleSpinBox,
18
+ QMainWindow,
19
+ QPushButton,
20
+ QSpinBox,
21
+ )
14
22
 
15
23
  import bec_widgets
16
24
  from bec_widgets.qt_utils.error_popups import SafeSlot as Slot
17
25
  from bec_widgets.qt_utils.toolbar import WidgetAction
18
26
  from bec_widgets.utils import UILoader
27
+ from bec_widgets.utils.bec_dispatcher import BECDispatcher
19
28
  from bec_widgets.utils.bec_widget import BECWidget
20
29
  from bec_widgets.utils.colors import get_accent_colors
21
30
  from bec_widgets.widgets.bec_progressbar.bec_progressbar import BECProgressBar
22
31
  from bec_widgets.widgets.device_line_edit.device_line_edit import DeviceLineEdit
23
32
  from bec_widgets.widgets.lmfit_dialog.lmfit_dialog import LMFitDialog
24
33
  from bec_widgets.widgets.positioner_box.positioner_box import PositionerBox
34
+ from bec_widgets.widgets.positioner_group.positioner_group import PositionerGroup
25
35
  from bec_widgets.widgets.stop_button.stop_button import StopButton
26
36
  from bec_widgets.widgets.toggle.toggle import ToggleSwitch
27
37
  from bec_widgets.widgets.waveform.waveform_widget import BECWaveformWidget
28
38
 
29
39
  MODULE_PATH = os.path.dirname(bec_widgets.__file__)
40
+ logger = bec_logger.logger
30
41
 
31
42
 
32
- class Alignment1D(BECWidget, QMainWindow):
43
+ class Alignment1D:
33
44
  """Alignment GUI to perform 1D scans"""
34
45
 
35
- # Emit a signal when a motion is ongoing
36
- motion_is_active = Signal(bool)
37
-
38
46
  def __init__(self, client=None, gui_id: Optional[str] = None) -> None:
39
- """Initialise the widget
47
+ """Initialization
40
48
 
41
49
  Args:
42
- parent: Parent widget.
43
- config: Configuration of the widget.
50
+ config: Configuration of the application.
44
51
  client: BEC client object.
45
52
  gui_id: GUI ID.
46
53
  """
47
- super().__init__(client=client, gui_id=gui_id)
48
- QMainWindow.__init__(self)
49
- self.get_bec_shortcuts()
54
+ self.bec_dispatcher = BECDispatcher(client=client)
55
+ self.client = self.bec_dispatcher.client if client is None else client
56
+ QApplication.instance().aboutToQuit.connect(self.close)
57
+ self.dev = self.client.device_manager.devices
58
+
50
59
  self._accent_colors = get_accent_colors()
51
60
  self.ui_file = "alignment_1d.ui"
52
61
  self.ui = None
@@ -57,28 +66,25 @@ class Alignment1D(BECWidget, QMainWindow):
57
66
  def init_ui(self):
58
67
  """Initialise the UI from QT Designer file"""
59
68
  current_path = os.path.dirname(__file__)
60
- self.ui = UILoader(self).loader(os.path.join(current_path, self.ui_file))
61
- self.setCentralWidget(self.ui)
69
+ self.ui = UILoader(None).loader(os.path.join(current_path, self.ui_file))
62
70
  # Customize the plotting widget
63
71
  self.waveform = self.ui.findChild(BECWaveformWidget, "bec_waveform_widget")
64
72
  self._customise_bec_waveform_widget()
65
73
  # Setup comboboxes for motor and signal selection
66
74
  # FIXME after changing the filtering in the combobox
67
- self._setup_motor_combobox()
68
75
  self._setup_signal_combobox()
69
76
  # Setup motor indicator
70
77
  self._setup_motor_indicator()
71
- # Connect spinboxes to scan Control
72
- self._setup_scan_control()
73
78
  # Setup progress bar
74
79
  self._setup_progress_bar()
75
80
  # Add actions buttons
76
81
  self._customise_buttons()
77
- # Customize the positioner box
78
- self._customize_positioner_box()
79
82
  # Hook scaninfo updates
80
83
  self.bec_dispatcher.connect_slot(self.scan_status_callback, MessageEndpoints.scan_status())
81
84
 
85
+ def show(self):
86
+ return self.ui.show()
87
+
82
88
  ##############################
83
89
  ############ SLOTS ###########
84
90
  ##############################
@@ -87,10 +93,8 @@ class Alignment1D(BECWidget, QMainWindow):
87
93
  def scan_status_callback(self, content: dict, _) -> None:
88
94
  """This slot allows to enable/disable the UI critical components when a scan is running"""
89
95
  if content["status"] in ["open"]:
90
- self.motion_is_active.emit(True)
91
96
  self.enable_ui(False)
92
97
  elif content["status"] in ["aborted", "halted", "closed"]:
93
- self.motion_is_active.emit(False)
94
98
  self.enable_ui(True)
95
99
 
96
100
  @Slot(tuple)
@@ -133,15 +137,11 @@ class Alignment1D(BECWidget, QMainWindow):
133
137
  def enable_ui(self, enable: bool) -> None:
134
138
  """Enable or disable the UI components"""
135
139
  # Enable/disable motor and signal selection
136
- self.ui.device_combobox.setEnabled(enable)
137
140
  self.ui.device_combobox_2.setEnabled(enable)
138
141
  # Enable/disable DAP selection
139
142
  self.ui.dap_combo_box.setEnabled(enable)
140
143
  # Enable/disable Scan Button
141
- self.ui.scan_button.setEnabled(enable)
142
- # Positioner control line
143
- # pylint: disable=protected-access
144
- self.ui.positioner_box._toogle_enable_buttons(enable)
144
+ # self.ui.scan_button.setEnabled(enable)
145
145
  # Disable move to buttons in LMFitDialog
146
146
  self.ui.findChild(LMFitDialog).set_actions_enabled(enable)
147
147
 
@@ -154,49 +154,20 @@ class Alignment1D(BECWidget, QMainWindow):
154
154
  fit_dialog = self.ui.findChild(LMFitDialog)
155
155
  fit_dialog.active_action_list = ["center", "center1", "center2"]
156
156
  fit_dialog.move_action.connect(self.move_to_center)
157
- scan_button = self.ui.findChild(QPushButton, "scan_button")
158
- scan_button.setStyleSheet(
159
- f"""
160
- QPushButton:enabled {{ background-color: {self._accent_colors.success.name()};color: white; }}
161
- QPushButton:disabled {{ background-color: grey;color: white; }}
162
- """
163
- )
164
157
  stop_button = self.ui.findChild(StopButton)
165
158
  stop_button.button.setText("Stop and Clear Queue")
166
159
  stop_button.button.clicked.connect(self.clear_queue)
167
160
 
168
161
  def _customise_bec_waveform_widget(self) -> None:
169
- """Customise the BEC Waveform Widget, i.e. clear the toolbar, add the DAP ROI selection to the toolbar.
170
- We also move the scan_control widget which is fully hidden and solely used for setting up the scan parameters to the toolbar.
171
- """
162
+ """Customise the BEC Waveform Widget, i.e. clear the toolbar"""
172
163
  self.waveform.toolbar.clear()
173
- toggle_switch = self.ui.findChild(ToggleSwitch, "toggle_switch")
174
- scan_control = self.ui.scan_control
175
- self.waveform.toolbar.populate_toolbar(
176
- {
177
- "label": WidgetAction(label="ENABLE DAP ROI", widget=toggle_switch),
178
- "scan_control": WidgetAction(widget=scan_control),
179
- },
180
- self.waveform,
181
- )
182
164
 
183
165
  def _setup_motor_indicator(self) -> None:
184
166
  """Setup the arrow item"""
185
167
  self.waveform.waveform.tick_item.add_to_plot()
186
- positioner_box = self.ui.findChild(PositionerBox)
168
+ positioner_box = self.ui.findChild(PositionerGroup)
187
169
  positioner_box.position_update.connect(self.waveform.waveform.tick_item.set_position)
188
- try:
189
- pos = float(positioner_box.ui.readback.text())
190
- except ValueError:
191
- pos = 0
192
- self.waveform.waveform.tick_item.set_position(pos)
193
-
194
- def _setup_motor_combobox(self) -> None:
195
- """Setup motor selection"""
196
- # FIXME after changing the filtering in the combobox
197
- motors = [name for name in self.dev if isinstance(self.dev.get(name), BECPositioner)]
198
- self.ui.device_combobox.setCurrentText(motors[0])
199
- self.ui.device_combobox.set_device_filter("Positioner")
170
+ self.waveform.waveform.tick_item.set_position(0)
200
171
 
201
172
  def _setup_signal_combobox(self) -> None:
202
173
  """Setup signal selection"""
@@ -205,31 +176,6 @@ class Alignment1D(BECWidget, QMainWindow):
205
176
  self.ui.device_combobox_2.setCurrentText(signals[0])
206
177
  self.ui.device_combobox_2.set_device_filter("Signal")
207
178
 
208
- def _setup_scan_control(self) -> None:
209
- """Setup scan control, connect spin and check boxes to the scan_control widget"""
210
- # Connect motor
211
- device_line_edit = self.ui.scan_control.arg_box.findChild(DeviceLineEdit)
212
- self.ui.device_combobox.currentTextChanged.connect(device_line_edit.setText)
213
- device_line_edit.setText(self.ui.device_combobox.currentText())
214
- # Connect start, stop, step, exp_time and relative check box
215
- spin_boxes = self.ui.scan_control.arg_box.findChildren(QDoubleSpinBox)
216
- start = self.ui.findChild(QDoubleSpinBox, "linescan_start")
217
- start.valueChanged.connect(spin_boxes[0].setValue)
218
- stop = self.ui.findChild(QDoubleSpinBox, "linescan_stop")
219
- stop.valueChanged.connect(spin_boxes[1].setValue)
220
- step = self.ui.findChild(QSpinBox, "linescan_step")
221
- step.valueChanged.connect(
222
- self.ui.scan_control.kwarg_boxes[0].findChildren(QSpinBox)[0].setValue
223
- )
224
- exp_time = self.ui.findChild(QDoubleSpinBox, "linescan_exp_time")
225
- exp_time.valueChanged.connect(
226
- self.ui.scan_control.kwarg_boxes[1].findChildren(QDoubleSpinBox)[0].setValue
227
- )
228
- relative = self.ui.findChild(QCheckBox, "linescan_relative")
229
- relative.toggled.connect(
230
- self.ui.scan_control.kwarg_boxes[0].findChildren(QCheckBox)[0].setChecked
231
- )
232
-
233
179
  def _setup_progress_bar(self) -> None:
234
180
  """Setup progress bar"""
235
181
  # FIXME once the BECScanProgressBar is implemented
@@ -238,18 +184,16 @@ class Alignment1D(BECWidget, QMainWindow):
238
184
  self.ui.bec_waveform_widget.new_scan.connect(self.reset_progress_bar)
239
185
  self.bec_dispatcher.connect_slot(self.update_progress_bar, MessageEndpoints.scan_progress())
240
186
 
241
- def _customize_positioner_box(self) -> None:
242
- """Customize the positioner Box, i.e. remove the stop button"""
243
- box = self.ui.findChild(PositionerBox)
244
- box.ui.stop.setVisible(False)
245
- box.ui.position_indicator.setFixedHeight(20)
187
+ def close(self):
188
+ logger.info("Disconnecting", repr(self.bec_dispatcher))
189
+ self.bec_dispatcher.disconnect_all()
190
+ logger.info("Shutting down BEC Client", repr(self.client))
191
+ self.client.shutdown()
246
192
 
247
193
 
248
194
  def main():
249
195
  import sys
250
196
 
251
- from qtpy.QtWidgets import QApplication # pylint: disable=ungrouped-imports
252
-
253
197
  app = QApplication(sys.argv)
254
198
  icon = QIcon()
255
199
  icon.addFile(