bec-widgets 0.81.0__py3-none-any.whl → 0.82.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.
Files changed (80) hide show
  1. CHANGELOG.md +50 -46
  2. PKG-INFO +1 -1
  3. bec_widgets/cli/client.py +1 -0
  4. bec_widgets/examples/__init__.py +0 -9
  5. bec_widgets/qt_utils/settings_dialog.py +107 -0
  6. bec_widgets/{widgets/toolbar → qt_utils}/toolbar.py +1 -30
  7. bec_widgets/widgets/{device_inputs → base_classes}/device_input_base.py +2 -0
  8. bec_widgets/widgets/{buttons/color_button → color_button}/color_button_plugin.py +1 -1
  9. bec_widgets/widgets/{buttons/color_button → color_button}/register_color_button.py +1 -1
  10. bec_widgets/widgets/device_combobox/assets/device_combobox_icon.png +0 -0
  11. bec_widgets/widgets/{device_inputs/device_combobox → device_combobox}/device_combobox.py +2 -2
  12. bec_widgets/widgets/device_combobox/device_combobox.pyproject +3 -0
  13. bec_widgets/widgets/{device_inputs/device_combobox → device_combobox}/device_combobox_plugin.py +6 -3
  14. bec_widgets/widgets/{device_inputs/device_combobox → device_combobox}/register_device_combobox.py +1 -3
  15. bec_widgets/widgets/device_line_edit/assets/line_edit_icon.png +0 -0
  16. bec_widgets/widgets/{device_inputs/device_line_edit → device_line_edit}/device_line_edit.py +2 -2
  17. bec_widgets/widgets/device_line_edit/device_line_edit.pyproject +3 -0
  18. bec_widgets/widgets/{device_inputs/device_line_edit → device_line_edit}/device_line_edit_plugin.py +6 -3
  19. bec_widgets/widgets/{device_inputs/device_line_edit → device_line_edit}/register_device_line_edit.py +1 -3
  20. bec_widgets/widgets/figure/plots/motor_map/motor_map.py +10 -8
  21. bec_widgets/widgets/figure/plots/waveform/waveform.py +8 -2
  22. bec_widgets/widgets/motor_map/motor_map_dialog/motor_map_settings.py +5 -31
  23. bec_widgets/widgets/motor_map/motor_map_dialog/motor_map_toolbar.py +2 -2
  24. bec_widgets/widgets/motor_map/motor_map_widget.py +6 -15
  25. bec_widgets/widgets/scan_control/scan_control.py +1 -1
  26. bec_widgets/widgets/scan_control/scan_group_box.py +1 -1
  27. bec_widgets/widgets/stop_button/assets/stop.png +0 -0
  28. bec_widgets/widgets/stop_button/register_stop_button.py +15 -0
  29. bec_widgets/widgets/{buttons/stop_button → stop_button}/stop_button.py +5 -12
  30. bec_widgets/widgets/stop_button/stop_button.pyproject +1 -0
  31. bec_widgets/widgets/stop_button/stop_button_plugin.py +57 -0
  32. bec_widgets/widgets/toggle/register_toggle_switch.py +15 -0
  33. bec_widgets/widgets/toggle/toggle.py +149 -0
  34. bec_widgets/widgets/toggle/toggle_switch.pyproject +1 -0
  35. bec_widgets/widgets/toggle/toggle_switch_plugin.py +54 -0
  36. {bec_widgets-0.81.0.dist-info → bec_widgets-0.82.1.dist-info}/METADATA +1 -1
  37. {bec_widgets-0.81.0.dist-info → bec_widgets-0.82.1.dist-info}/RECORD +58 -64
  38. pyproject.toml +1 -1
  39. tests/unit_tests/client_mocks.py +8 -0
  40. tests/unit_tests/test_device_input_base.py +2 -2
  41. tests/unit_tests/test_device_input_widgets.py +4 -2
  42. tests/unit_tests/test_motor_map_widget.py +196 -0
  43. tests/unit_tests/test_setting_dialog.py +97 -0
  44. tests/unit_tests/test_stop_button.py +5 -2
  45. tests/unit_tests/test_toggle.py +38 -0
  46. bec_widgets/examples/motor_movement/__init__.py +0 -9
  47. bec_widgets/examples/motor_movement/motor_control_compilations.py +0 -250
  48. bec_widgets/examples/motor_movement/motor_controller.ui +0 -926
  49. bec_widgets/widgets/buttons/__init__.py +0 -1
  50. bec_widgets/widgets/device_inputs/__init__.py +0 -2
  51. bec_widgets/widgets/device_inputs/device_combobox/device_combobox.pyproject +0 -4
  52. bec_widgets/widgets/device_inputs/device_combobox/launch_device_combobox.py +0 -11
  53. bec_widgets/widgets/device_inputs/device_line_edit/device_line_edit.pyproject +0 -4
  54. bec_widgets/widgets/device_inputs/device_line_edit/launch_device_line_edit.py +0 -11
  55. bec_widgets/widgets/motor_control/motor_control.py +0 -252
  56. bec_widgets/widgets/motor_control/motor_table/motor_table.py +0 -484
  57. bec_widgets/widgets/motor_control/motor_table/motor_table.ui +0 -113
  58. bec_widgets/widgets/motor_control/movement_absolute/movement_absolute.py +0 -159
  59. bec_widgets/widgets/motor_control/movement_absolute/movement_absolute.ui +0 -149
  60. bec_widgets/widgets/motor_control/movement_relative/__init__.py +0 -0
  61. bec_widgets/widgets/motor_control/movement_relative/movement_relative.py +0 -230
  62. bec_widgets/widgets/motor_control/movement_relative/movement_relative.ui +0 -298
  63. bec_widgets/widgets/motor_control/selection/__init__.py +0 -0
  64. bec_widgets/widgets/motor_control/selection/selection.py +0 -110
  65. bec_widgets/widgets/motor_control/selection/selection.ui +0 -69
  66. bec_widgets/widgets/toolbar/__init__.py +0 -1
  67. tests/unit_tests/test_motor_control.py +0 -588
  68. /bec_widgets/{widgets/buttons/color_button → qt_utils}/__init__.py +0 -0
  69. /bec_widgets/widgets/{buttons/stop_button → base_classes}/__init__.py +0 -0
  70. /bec_widgets/widgets/{device_inputs/device_combobox → color_button}/__init__.py +0 -0
  71. /bec_widgets/widgets/{buttons/color_button → color_button}/assets/color_button.png +0 -0
  72. /bec_widgets/widgets/{buttons/color_button → color_button}/color_button.py +0 -0
  73. /bec_widgets/widgets/{buttons/color_button → color_button}/color_button.pyproject +0 -0
  74. /bec_widgets/widgets/{device_inputs/device_line_edit → device_combobox}/__init__.py +0 -0
  75. /bec_widgets/widgets/{motor_control → device_line_edit}/__init__.py +0 -0
  76. /bec_widgets/widgets/{motor_control/motor_table → stop_button}/__init__.py +0 -0
  77. /bec_widgets/widgets/{motor_control/movement_absolute → toggle}/__init__.py +0 -0
  78. {bec_widgets-0.81.0.dist-info → bec_widgets-0.82.1.dist-info}/WHEEL +0 -0
  79. {bec_widgets-0.81.0.dist-info → bec_widgets-0.82.1.dist-info}/entry_points.txt +0 -0
  80. {bec_widgets-0.81.0.dist-info → bec_widgets-0.82.1.dist-info}/licenses/LICENSE +0 -0
CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.82.1 (2024-07-07)
4
+
5
+ ### Fix
6
+
7
+ * fix(motor_map): bug where motors without limits were selected ([`c78cd89`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c78cd898f203f950d7cb589eb5609feaa88062cf))
8
+
9
+ ### Refactor
10
+
11
+ * refactor(setting_dialog): moved to qt_utils ([`3826bb3`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/3826bb3d9e870e85709b5b20ef09a4d22641280c))
12
+
13
+ * refactor(toolbar): toolbar moved from widgets to qt_utils ([`7ffc06f`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/7ffc06f3c7ddd86a1681408a75221b9bbadb236b))
14
+
15
+ ### Test
16
+
17
+ * test(setting_dialog): tests added ([`74a249b`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/74a249bd065d01006cb532bfff2a9bfedb34b592))
18
+
19
+ ### Unknown
20
+
21
+ * tests(motor_map_widget): tests added ([`734f4c7`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/734f4c77507a1edafd477d81b5f7401d8e759be2))
22
+
23
+ * feat(settings_dialog):apply button ([`2020953`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/2020953b933b6fcad61ecc770588d39518c26fdd))
24
+
25
+ ## v0.82.0 (2024-07-07)
26
+
27
+ ### Feature
28
+
29
+ * feat(toggle): added angular component-like toggle ([`b9bff38`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/b9bff38b64b86f06b3bc047922ef9df0c7d32e71))
30
+
31
+ ### Refactor
32
+
33
+ * refactor(device_input): DeviceComboBox and DeviceLineEdit moved to top layer of widgets ([`f048629`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/f04862933f049030554086adef3ec9e1aebd3eda))
34
+
35
+ * refactor(stop_button): moved to top layer, plugin added ([`f5b8375`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/f5b8375fd36e3bb681de571da86a6c0bdb3cb6f0))
36
+
37
+ * refactor(motor_map_widget): removed restriction of only PySide6 for widget ([`db1cdf4`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/db1cdf42806fef6d7c6d2db83528f32df3f9751d))
38
+
39
+ * refactor(color_button): ColorButton moved to top level of widgets ([`fa1e86f`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/fa1e86ff07b25d2c47c73117b00765b8e2f25da4))
40
+
41
+ ## v0.81.2 (2024-07-07)
42
+
43
+ ### Fix
44
+
45
+ * fix(waveform): scan_history error check for IndexError ([`dd1875e`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/dd1875ea5cc18bcef9aad743347a8accf144c08d))
46
+
47
+ ## v0.81.1 (2024-07-07)
48
+
49
+ ### Fix
50
+
51
+ * fix(motor_control): temporary remove of motor control widgets ([`99114f1`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/99114f14f62202e1fd8bf145616fa8c69937ada4))
52
+
3
53
  ## v0.81.0 (2024-07-06)
4
54
 
5
55
  ### Feature
@@ -86,8 +136,6 @@
86
136
 
87
137
  * feat(bec_connector): export config to yaml ([`a391f30`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/a391f3018c50fee6a4a06884491b957df80c3cd3))
88
138
 
89
- * feat(utils): colors added convertor for rgba to hex ([`572f2fb`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/572f2fb8110d5cb0e80f3ca45ce57ef405572456))
90
-
91
139
  ### Fix
92
140
 
93
141
  * fix(waveform): scatter 2D brush error ([`215d59c`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/215d59c8bfe7fda9aff8cec8353bef9e1ce2eca1))
@@ -97,47 +145,3 @@
97
145
  * fix(figure): if/else logic corrected in subplot_factory ([`3e78723`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/3e787234c7274b0698423d7bf9a4c54ec46bad5f))
98
146
 
99
147
  * fix(image): processing of already displayed data; closes #106 ([`1173510`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/1173510105d2d70d7e498c2ac1e122cea3a16597))
100
-
101
- * fix(bec_figure): full reconstruction with config from other bec figure ([`b6e1e20`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/b6e1e20b7c8549bb092e981062329e601411dda6))
102
-
103
- * fix(motor_map): API changes updates current visualisation; motor_map can be initialised from config ([`2e2d422`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/2e2d422910685a2527a3d961a468c787f771ca44))
104
-
105
- * fix(image): image add_custom_image fixed, closes #225 ([`f0556e4`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/f0556e44113ffee66cf735aa2dd758c62cb634f4))
106
-
107
- * fix(figure): subplot methods consolidated; added subplot factory ([`4a97105`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/4a97105e4bd2ce77d72dfe5f8307dd9ee65b21b0))
108
-
109
- * fix(image): image can be fully reconstructed from config ([`797f73c`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/797f73c39aa73e07d6311f3de4baea53f6c380e0))
110
-
111
- * fix(image_item): vrange added int for pydantic model check ([`b8f796f`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/b8f796fd3fcc15641e8fc6a3ca75c344ce90fc45))
112
-
113
- * fix(bec_figure): waveforms can be initialised from the config; widgets are deleteLater after removal ([`78673ea`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/78673ea11a47aad878128197ae6213925228ed59))
114
-
115
- ### Unknown
116
-
117
- * Resolve "add VT100 console executing BEC as a widget" ([`c6a14c0`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c6a14c0768a90695567a83a7895247ed0c64f3ce))
118
-
119
- ## v0.76.1 (2024-06-29)
120
-
121
- ### Fix
122
-
123
- * fix(plugins): fixes and tests for auto-gen plugins ([`c42511d`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c42511dd44cc13577e108a6cef3166376e594f54))
124
-
125
- ## v0.76.0 (2024-06-28)
126
-
127
- ### Feature
128
-
129
- * feat(designer): added support for creating designer plugins automatically ([`c1dd0ee`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/c1dd0ee1906dba1f2e2ae9ce40a84d55c26a1cce))
130
-
131
- ### Fix
132
-
133
- * fix: fixed qwidget inheritance for ring progress bar ([`0610d2f`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/0610d2f9f027f8659e7149f2dfbb316ff30e337d))
134
-
135
- ### Unknown
136
-
137
- * fix:parent set as first kwarg TextBox and WebsiteWidget ([`a45c407`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/a45c4075684b93bfdcee03e5a416b84f61d3bc6f))
138
-
139
- ## v0.75.0 (2024-06-26)
140
-
141
- ### Feature
142
-
143
- * feat(widgets): added simple bec queue widget ([`3faee98`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/3faee98ec80041a27e4c1f1156178de6f9dcdc63))
PKG-INFO CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bec_widgets
3
- Version: 0.81.0
3
+ Version: 0.82.1
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
@@ -21,6 +21,7 @@ class Widgets(str, enum.Enum):
21
21
  BECStatusBox = "BECStatusBox"
22
22
  RingProgressBar = "RingProgressBar"
23
23
  ScanControl = "ScanControl"
24
+ StopButton = "StopButton"
24
25
  TextBox = "TextBox"
25
26
  VSCodeEditor = "VSCodeEditor"
26
27
  WebsiteWidget = "WebsiteWidget"
@@ -1,9 +0,0 @@
1
- from .motor_movement import (
2
- MotorControlApp,
3
- MotorControlMap,
4
- MotorControlPanel,
5
- MotorControlPanelAbsolute,
6
- MotorControlPanelRelative,
7
- MotorCoordinateTable,
8
- MotorThread,
9
- )
@@ -0,0 +1,107 @@
1
+ from qtpy.QtCore import Slot
2
+ from qtpy.QtWidgets import QDialog, QDialogButtonBox, QHBoxLayout, QPushButton, QVBoxLayout, QWidget
3
+
4
+
5
+ class SettingWidget(QWidget):
6
+ """
7
+ Abstract class for a settings widget to enforce the implementation of the accept_changes and display_current_settings.
8
+ Can be used for toolbar actions to display the settings of a widget.
9
+
10
+ Args:
11
+ target_widget (QWidget): The widget that the settings will be taken from and applied to.
12
+ """
13
+
14
+ def __init__(self, parent=None, *args, **kwargs):
15
+ super().__init__(parent, *args, **kwargs)
16
+
17
+ self.target_widget = None
18
+
19
+ def set_target_widget(self, target_widget: QWidget):
20
+ self.target_widget = target_widget
21
+
22
+ @Slot()
23
+ def accept_changes(self):
24
+ """
25
+ Accepts the changes made in the settings widget and applies them to the target widget.
26
+ """
27
+ pass
28
+
29
+ @Slot(dict)
30
+ def display_current_settings(self, config_dict: dict):
31
+ """
32
+ Displays the current settings of the target widget in the settings widget.
33
+
34
+ Args:
35
+ config_dict(dict): The current settings of the target widget.
36
+ """
37
+ pass
38
+
39
+
40
+ class SettingsDialog(QDialog):
41
+ """
42
+ Dialog to display and edit the settings of a widget with accept and cancel buttons.
43
+
44
+ Args:
45
+ parent (QWidget): The parent widget of the dialog.
46
+ target_widget (QWidget): The widget that the settings will be taken from and applied to.
47
+ settings_widget (SettingWidget): The widget that will display the settings.
48
+ """
49
+
50
+ def __init__(
51
+ self,
52
+ parent=None,
53
+ settings_widget: SettingWidget = None,
54
+ window_title: str = "Settings",
55
+ config: dict = None,
56
+ *args,
57
+ **kwargs,
58
+ ):
59
+ super().__init__(parent, *args, **kwargs)
60
+
61
+ self.setModal(False)
62
+
63
+ self.setWindowTitle(window_title)
64
+
65
+ self.widget = settings_widget
66
+ self.widget.set_target_widget(parent)
67
+ if config is None:
68
+ config = parent.get_config()
69
+
70
+ self.widget.display_current_settings(config)
71
+
72
+ self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
73
+
74
+ self.apply_button = QPushButton("Apply")
75
+
76
+ button_layout = QHBoxLayout()
77
+ button_layout.addWidget(self.button_box.button(QDialogButtonBox.Cancel))
78
+ button_layout.addWidget(self.apply_button)
79
+ button_layout.addWidget(self.button_box.button(QDialogButtonBox.Ok))
80
+
81
+ self.button_box.accepted.connect(self.accept)
82
+ self.button_box.rejected.connect(self.reject)
83
+ self.apply_button.clicked.connect(self.apply_changes)
84
+
85
+ self.layout = QVBoxLayout(self)
86
+ self.layout.setContentsMargins(5, 5, 5, 5)
87
+ self.layout.addWidget(self.widget)
88
+ self.layout.addLayout(button_layout)
89
+
90
+ ok_button = self.button_box.button(QDialogButtonBox.Ok)
91
+ ok_button.setDefault(True)
92
+ ok_button.setAutoDefault(True)
93
+
94
+ @Slot()
95
+ def accept(self):
96
+ """
97
+ Accept the changes made in the settings widget and close the dialog.
98
+ """
99
+ self.widget.accept_changes()
100
+ super().accept()
101
+
102
+ @Slot()
103
+ def apply_changes(self):
104
+ """
105
+ Apply the changes made in the settings widget without closing the dialog.
106
+ """
107
+ self.widget.accept_changes()
@@ -3,8 +3,7 @@ from collections import defaultdict
3
3
 
4
4
  # pylint: disable=no-name-in-module
5
5
  from qtpy.QtCore import QSize
6
- from qtpy.QtGui import QAction
7
- from qtpy.QtWidgets import QHBoxLayout, QLabel, QSpinBox, QToolBar, QWidget
6
+ from qtpy.QtWidgets import QToolBar, QWidget
8
7
 
9
8
 
10
9
  class ToolBarAction(ABC):
@@ -18,34 +17,6 @@ class ToolBarAction(ABC):
18
17
  """
19
18
 
20
19
 
21
- class ColumnAdjustAction(ToolBarAction):
22
- """Toolbar spinbox to adjust number of columns in the plot layout"""
23
-
24
- def add_to_toolbar(self, toolbar: QToolBar, target: QWidget):
25
- """Creates a access history button for the toolbar.
26
-
27
- Args:
28
- toolbar (QToolBar): The toolbar to add the action to.
29
- target (QWidget): The widget that the 'Access Scan History' action will be targeted.
30
-
31
- Returns:
32
- QAction: The 'Access Scan History' action created for the toolbar.
33
- """
34
- widget = QWidget()
35
- layout = QHBoxLayout(widget)
36
-
37
- label = QLabel("Columns:")
38
- spin_box = QSpinBox()
39
- spin_box.setMinimum(1) # Set minimum value
40
- spin_box.setMaximum(10) # Set maximum value
41
- spin_box.setValue(target.get_column_count()) # Initial value
42
- spin_box.valueChanged.connect(lambda value: target.set_column_count(value))
43
-
44
- layout.addWidget(label)
45
- layout.addWidget(spin_box)
46
- toolbar.addWidget(widget)
47
-
48
-
49
20
  class ModularToolBar(QToolBar):
50
21
  """Modular toolbar with optional automatic initialization.
51
22
  Args:
@@ -25,6 +25,7 @@ class DeviceInputBase(BECConnector):
25
25
  super().__init__(client=client, config=config, gui_id=gui_id)
26
26
 
27
27
  self.get_bec_shortcuts()
28
+ self._device_filter = None
28
29
  self._devices = []
29
30
 
30
31
  @property
@@ -56,6 +57,7 @@ class DeviceInputBase(BECConnector):
56
57
  """
57
58
  self.validate_device_filter(device_filter)
58
59
  self.config.device_filter = device_filter
60
+ self._device_filter = device_filter
59
61
 
60
62
  def set_default_device(self, default_device: str):
61
63
  """
@@ -3,7 +3,7 @@ import os
3
3
  from qtpy.QtDesigner import QDesignerCustomWidgetInterface
4
4
  from qtpy.QtGui import QIcon
5
5
 
6
- from bec_widgets.widgets.buttons.color_button.color_button import ColorButton
6
+ from bec_widgets.widgets.color_button.color_button import ColorButton
7
7
 
8
8
  DOM_XML = """
9
9
  <ui language='c++'>
@@ -6,7 +6,7 @@ def main(): # pragma: no cover
6
6
  return
7
7
  from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
8
8
 
9
- from bec_widgets.widgets.buttons.color_button.color_button_plugin import ColorButtonPlugin
9
+ from bec_widgets.widgets.color_button.color_button_plugin import ColorButtonPlugin
10
10
 
11
11
  QPyDesignerCustomWidgetCollection.addCustomWidget(ColorButtonPlugin())
12
12
 
@@ -2,10 +2,10 @@ from typing import TYPE_CHECKING
2
2
 
3
3
  from qtpy.QtWidgets import QComboBox
4
4
 
5
- from bec_widgets.widgets.device_inputs.device_input_base import DeviceInputBase, DeviceInputConfig
5
+ from bec_widgets.widgets.base_classes.device_input_base import DeviceInputBase, DeviceInputConfig
6
6
 
7
7
  if TYPE_CHECKING:
8
- from bec_widgets.widgets.device_inputs.device_input_base import DeviceInputConfig
8
+ from bec_widgets.widgets.base_classes.device_input_base import DeviceInputConfig
9
9
 
10
10
 
11
11
  class DeviceComboBox(DeviceInputBase, QComboBox):
@@ -0,0 +1,3 @@
1
+ {
2
+ "files": ["device_combobox.py"]
3
+ }
@@ -1,10 +1,11 @@
1
1
  # Copyright (C) 2022 The Qt Company Ltd.
2
2
  # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
+ import os
3
4
 
4
5
  from qtpy.QtDesigner import QDesignerCustomWidgetInterface
5
6
  from qtpy.QtGui import QIcon
6
7
 
7
- from bec_widgets.widgets.device_inputs import DeviceComboBox
8
+ from bec_widgets.widgets.device_combobox.device_combobox import DeviceComboBox
8
9
 
9
10
  DOM_XML = """
10
11
  <ui language='c++'>
@@ -27,10 +28,12 @@ class DeviceComboBoxPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
27
28
  return DOM_XML
28
29
 
29
30
  def group(self):
30
- return ""
31
+ return "BEC Device Inputs"
31
32
 
32
33
  def icon(self):
33
- return QIcon()
34
+ current_path = os.path.dirname(__file__)
35
+ icon_path = os.path.join(current_path, "assets", "device_combobox_icon.png")
36
+ return QIcon(icon_path)
34
37
 
35
38
  def includeFile(self):
36
39
  return "device_combobox"
@@ -6,9 +6,7 @@ def main(): # pragma: no cover
6
6
  return
7
7
  from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
8
8
 
9
- from bec_widgets.widgets.device_inputs.device_combobox.device_combobox_plugin import (
10
- DeviceComboBoxPlugin,
11
- )
9
+ from bec_widgets.widgets.device_combobox.device_combobox_plugin import DeviceComboBoxPlugin
12
10
 
13
11
  QPyDesignerCustomWidgetCollection.addCustomWidget(DeviceComboBoxPlugin())
14
12
 
@@ -3,10 +3,10 @@ from typing import TYPE_CHECKING
3
3
  from qtpy.QtCore import QSize
4
4
  from qtpy.QtWidgets import QCompleter, QLineEdit, QSizePolicy
5
5
 
6
- from bec_widgets.widgets.device_inputs.device_input_base import DeviceInputBase, DeviceInputConfig
6
+ from bec_widgets.widgets.base_classes.device_input_base import DeviceInputBase, DeviceInputConfig
7
7
 
8
8
  if TYPE_CHECKING:
9
- from bec_widgets.widgets.device_inputs.device_input_base import DeviceInputConfig
9
+ from bec_widgets.widgets.base_classes.device_input_base import DeviceInputConfig
10
10
 
11
11
 
12
12
  class DeviceLineEdit(DeviceInputBase, QLineEdit):
@@ -0,0 +1,3 @@
1
+ {
2
+ "files": ["device_line_edit.py"]
3
+ }
@@ -1,10 +1,11 @@
1
1
  # Copyright (C) 2022 The Qt Company Ltd.
2
2
  # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
+ import os
3
4
 
4
5
  from qtpy.QtDesigner import QDesignerCustomWidgetInterface
5
6
  from qtpy.QtGui import QIcon
6
7
 
7
- from bec_widgets.widgets.device_inputs import DeviceLineEdit
8
+ from bec_widgets.widgets.device_line_edit.device_line_edit import DeviceLineEdit
8
9
 
9
10
  DOM_XML = """
10
11
  <ui language='c++'>
@@ -27,10 +28,12 @@ class DeviceLineEditPlugin(QDesignerCustomWidgetInterface): # pragma: no cover
27
28
  return DOM_XML
28
29
 
29
30
  def group(self):
30
- return ""
31
+ return "BEC Device Inputs"
31
32
 
32
33
  def icon(self):
33
- return QIcon()
34
+ current_path = os.path.dirname(__file__)
35
+ icon_path = os.path.join(current_path, "assets", "line_edit_icon.png")
36
+ return QIcon(icon_path)
34
37
 
35
38
  def includeFile(self):
36
39
  return "device_line_edit"
@@ -6,9 +6,7 @@ def main(): # pragma: no cover
6
6
  return
7
7
  from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection
8
8
 
9
- from bec_widgets.widgets.device_inputs.device_line_edit.device_line_edit_plugin import (
10
- DeviceLineEditPlugin,
11
- )
9
+ from bec_widgets.widgets.device_line_edit.device_line_edit_plugin import DeviceLineEditPlugin
12
10
 
13
11
  QPyDesignerCustomWidgetCollection.addCustomWidget(DeviceLineEditPlugin())
14
12
 
@@ -271,11 +271,12 @@ class BECMotorMap(BECPlotBase):
271
271
  def _swap_limit_map(self):
272
272
  """Swap the limit map."""
273
273
  self.plot_item.removeItem(self.plot_components["limit_map"])
274
- self.plot_components["limit_map"] = self._make_limit_map(
275
- self.config.signals.x.limits, self.config.signals.y.limits
276
- )
277
- self.plot_components["limit_map"].setZValue(-1)
278
- self.plot_item.addItem(self.plot_components["limit_map"])
274
+ if self.config.signals.x.limits is not None and self.config.signals.y.limits is not None:
275
+ self.plot_components["limit_map"] = self._make_limit_map(
276
+ self.config.signals.x.limits, self.config.signals.y.limits
277
+ )
278
+ self.plot_components["limit_map"].setZValue(-1)
279
+ self.plot_item.addItem(self.plot_components["limit_map"])
279
280
 
280
281
  def _make_motor_map(self):
281
282
  """
@@ -284,9 +285,10 @@ class BECMotorMap(BECPlotBase):
284
285
  # Create limit map
285
286
  motor_x_limit = self.config.signals.x.limits
286
287
  motor_y_limit = self.config.signals.y.limits
287
- self.plot_components["limit_map"] = self._make_limit_map(motor_x_limit, motor_y_limit)
288
- self.plot_item.addItem(self.plot_components["limit_map"])
289
- self.plot_components["limit_map"].setZValue(-1)
288
+ if motor_x_limit is not None or motor_y_limit is not None:
289
+ self.plot_components["limit_map"] = self._make_limit_map(motor_x_limit, motor_y_limit)
290
+ self.plot_item.addItem(self.plot_components["limit_map"])
291
+ self.plot_components["limit_map"].setZValue(-1)
290
292
 
291
293
  # Create scatter plot
292
294
  scatter_size = self.config.scatter_size
@@ -221,6 +221,7 @@ class BECWaveform(BECPlotBase):
221
221
  label: str | None = None,
222
222
  validate: bool = True,
223
223
  dap: str | None = None, # TODO add dap custom curve wrapper
224
+ **kwargs,
224
225
  ) -> BECCurve:
225
226
  """
226
227
  Plot a curve to the plot widget.
@@ -244,7 +245,7 @@ class BECWaveform(BECPlotBase):
244
245
  """
245
246
 
246
247
  if x is not None and y is not None:
247
- return self.add_curve_custom(x=x, y=y, label=label, color=color)
248
+ return self.add_curve_custom(x=x, y=y, label=label, color=color, **kwargs)
248
249
  else:
249
250
  if dap:
250
251
  self.add_dap(x_name=x_name, y_name=y_name, dap=dap)
@@ -259,6 +260,7 @@ class BECWaveform(BECPlotBase):
259
260
  color_map_z=color_map_z,
260
261
  label=label,
261
262
  validate_bec=validate,
263
+ **kwargs,
262
264
  )
263
265
 
264
266
  def add_curve_custom(
@@ -754,7 +756,11 @@ class BECWaveform(BECPlotBase):
754
756
  self.update_dap, MessageEndpoints.dap_response(self.scan_id)
755
757
  )
756
758
  if scan_index is not None:
757
- self.scan_id = self.queue.scan_storage.storage[scan_index].scan_id
759
+ try:
760
+ self.scan_id = self.queue.scan_storage.storage[scan_index].scan_id
761
+ except IndexError:
762
+ print(f"Scan index {scan_index} out of range.")
763
+ return
758
764
  elif scan_id is not None:
759
765
  self.scan_id = scan_id
760
766
 
@@ -1,19 +1,19 @@
1
1
  import os
2
2
 
3
3
  from qtpy.QtCore import Slot
4
- from qtpy.QtWidgets import QDialog, QDialogButtonBox, QLabel, QVBoxLayout, QWidget
4
+ from qtpy.QtWidgets import QVBoxLayout
5
5
 
6
+ from bec_widgets.qt_utils.settings_dialog import SettingWidget
6
7
  from bec_widgets.utils import UILoader
7
8
  from bec_widgets.utils.widget_io import WidgetIO
8
9
 
9
10
 
10
- class MotorMapSettings(QWidget):
11
- def __init__(self, parent=None, target_widget: QWidget = None, *args, **kwargs):
11
+ class MotorMapSettings(SettingWidget):
12
+ def __init__(self, parent=None, *args, **kwargs):
12
13
  super().__init__(parent, *args, **kwargs)
13
14
  current_path = os.path.dirname(__file__)
14
15
 
15
16
  self.ui = UILoader(self).loader(os.path.join(current_path, "motor_map_settings.ui"))
16
- self.target_widget = target_widget
17
17
 
18
18
  self.layout = QVBoxLayout(self)
19
19
  self.layout.addWidget(self.ui)
@@ -36,7 +36,7 @@ class MotorMapSettings(QWidget):
36
36
  precision = WidgetIO.get_value(self.ui.precision)
37
37
  scatter_size = WidgetIO.get_value(self.ui.scatter_size)
38
38
  background_intensity = int(WidgetIO.get_value(self.ui.background_value) * 0.01 * 255)
39
- color = self.ui.color.color().toTuple()
39
+ color = self.ui.color.get_color("RGBA")
40
40
 
41
41
  if self.target_widget is not None:
42
42
  self.target_widget.set_max_points(max_points)
@@ -45,29 +45,3 @@ class MotorMapSettings(QWidget):
45
45
  self.target_widget.set_scatter_size(scatter_size)
46
46
  self.target_widget.set_background_value(background_intensity)
47
47
  self.target_widget.set_color(color)
48
-
49
-
50
- class MotorMapDialog(QDialog):
51
- def __init__(self, parent=None, target_widget: QWidget = None, *args, **kwargs):
52
- super().__init__(parent, *args, **kwargs)
53
-
54
- self.setModal(False)
55
-
56
- self.setWindowTitle("Motor Map Settings")
57
-
58
- self.target_widget = target_widget
59
- self.widget = MotorMapSettings(target_widget=self.target_widget)
60
- self.widget.display_current_settings(self.target_widget._config_dict)
61
- self.button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
62
-
63
- self.button_box.accepted.connect(self.accept)
64
- self.button_box.rejected.connect(self.reject)
65
-
66
- self.layout = QVBoxLayout(self)
67
- self.layout.addWidget(self.widget)
68
- self.layout.addWidget(self.button_box)
69
-
70
- @Slot()
71
- def accept(self):
72
- self.widget.accept_changes()
73
- super().accept()
@@ -4,8 +4,8 @@ from qtpy.QtCore import QSize
4
4
  from qtpy.QtGui import QAction, QIcon
5
5
  from qtpy.QtWidgets import QHBoxLayout, QLabel, QWidget
6
6
 
7
- from bec_widgets.widgets.device_inputs import DeviceComboBox
8
- from bec_widgets.widgets.toolbar.toolbar import ToolBarAction
7
+ from bec_widgets.qt_utils.toolbar import ToolBarAction
8
+ from bec_widgets.widgets.device_combobox.device_combobox import DeviceComboBox
9
9
 
10
10
 
11
11
  class DeviceSelectionAction(ToolBarAction):
@@ -2,20 +2,20 @@ from __future__ import annotations
2
2
 
3
3
  import sys
4
4
 
5
- from qtpy import PYSIDE6
6
5
  from qtpy.QtWidgets import QVBoxLayout, QWidget
7
6
 
7
+ from bec_widgets.qt_utils.settings_dialog import SettingsDialog
8
+ from bec_widgets.qt_utils.toolbar import ModularToolBar
8
9
  from bec_widgets.utils import BECConnector
9
10
  from bec_widgets.widgets.figure import BECFigure
10
11
  from bec_widgets.widgets.figure.plots.motor_map.motor_map import MotorMapConfig
11
- from bec_widgets.widgets.motor_map.motor_map_dialog.motor_map_settings import MotorMapDialog
12
+ from bec_widgets.widgets.motor_map.motor_map_dialog.motor_map_settings import MotorMapSettings
12
13
  from bec_widgets.widgets.motor_map.motor_map_dialog.motor_map_toolbar import (
13
14
  ConnectAction,
14
15
  DeviceSelectionAction,
15
16
  ResetHistoryAction,
16
17
  SettingsAction,
17
18
  )
18
- from bec_widgets.widgets.toolbar import ModularToolBar
19
19
 
20
20
 
21
21
  class BECMotorMapWidget(BECConnector, QWidget):
@@ -37,10 +37,6 @@ class BECMotorMapWidget(BECConnector, QWidget):
37
37
  client=None,
38
38
  gui_id: str | None = None,
39
39
  ) -> None:
40
- if not PYSIDE6:
41
- raise RuntimeError(
42
- "PYSIDE6 is not available in the environment. This widget is compatible only with PySide6."
43
- )
44
40
  if config is None:
45
41
  config = MotorMapConfig(widget_class=self.__class__.__name__)
46
42
  else:
@@ -97,7 +93,9 @@ class BECMotorMapWidget(BECConnector, QWidget):
97
93
  toolbar_y.setStyleSheet("QComboBox {{ background-color: " "; }}")
98
94
 
99
95
  def show_settings(self) -> None:
100
- dialog = MotorMapDialog(self, target_widget=self)
96
+ dialog = SettingsDialog(
97
+ self, settings_widget=MotorMapSettings(), window_title="Motor Map Settings"
98
+ )
101
99
  dialog.exec()
102
100
 
103
101
  ###################################
@@ -216,13 +214,6 @@ class BECMotorMapWidget(BECConnector, QWidget):
216
214
 
217
215
 
218
216
  def main(): # pragma: no cover
219
-
220
- if not PYSIDE6:
221
- print(
222
- "PYSIDE6 is not available in the environment. UI files with BEC custom widgets are runnable only with PySide6."
223
- )
224
- return
225
-
226
217
  from qtpy.QtWidgets import QApplication
227
218
 
228
219
  app = QApplication(sys.argv)