bec-widgets 0.79.3__py3-none-any.whl → 0.82.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 (89) hide show
  1. .gitlab-ci.yml +0 -1
  2. .pylintrc +1 -1
  3. CHANGELOG.md +52 -62
  4. PKG-INFO +1 -4
  5. README.md +2 -2
  6. bec_widgets/cli/client.py +3 -2
  7. bec_widgets/cli/generate_cli.py +11 -10
  8. bec_widgets/cli/rpc_wigdet_handler.py +1 -1
  9. bec_widgets/examples/__init__.py +0 -9
  10. bec_widgets/utils/bec_connector.py +2 -1
  11. bec_widgets/utils/bec_dispatcher.py +3 -3
  12. bec_widgets/utils/bec_widget.py +2 -0
  13. bec_widgets/utils/entry_validator.py +1 -1
  14. bec_widgets/utils/plugin_utils.py +80 -10
  15. bec_widgets/utils/ui_loader.py +85 -26
  16. bec_widgets/widgets/{device_inputs → base_classes}/device_input_base.py +2 -0
  17. bec_widgets/widgets/color_button/color_button.py +36 -0
  18. bec_widgets/widgets/{buttons/color_button → color_button}/color_button_plugin.py +1 -1
  19. bec_widgets/widgets/{buttons/color_button → color_button}/register_color_button.py +1 -1
  20. bec_widgets/widgets/device_combobox/assets/device_combobox_icon.png +0 -0
  21. bec_widgets/widgets/{device_inputs/device_combobox → device_combobox}/device_combobox.py +2 -2
  22. bec_widgets/widgets/device_combobox/device_combobox.pyproject +3 -0
  23. bec_widgets/widgets/{device_inputs/device_combobox → device_combobox}/device_combobox_plugin.py +6 -3
  24. bec_widgets/widgets/{device_inputs/device_combobox → device_combobox}/register_device_combobox.py +1 -3
  25. bec_widgets/widgets/device_line_edit/assets/line_edit_icon.png +0 -0
  26. bec_widgets/widgets/{device_inputs/device_line_edit → device_line_edit}/device_line_edit.py +2 -2
  27. bec_widgets/widgets/device_line_edit/device_line_edit.pyproject +3 -0
  28. bec_widgets/widgets/{device_inputs/device_line_edit → device_line_edit}/device_line_edit_plugin.py +6 -3
  29. bec_widgets/widgets/{device_inputs/device_line_edit → device_line_edit}/register_device_line_edit.py +1 -3
  30. bec_widgets/widgets/figure/plots/waveform/waveform.py +8 -2
  31. bec_widgets/widgets/motor_map/motor_map_dialog/motor_map_settings.py +1 -1
  32. bec_widgets/widgets/motor_map/motor_map_dialog/motor_map_toolbar.py +1 -1
  33. bec_widgets/widgets/motor_map/motor_map_widget.py +0 -12
  34. bec_widgets/widgets/scan_control/scan_control.py +1 -1
  35. bec_widgets/widgets/scan_control/scan_group_box.py +1 -1
  36. bec_widgets/widgets/stop_button/assets/stop.png +0 -0
  37. bec_widgets/widgets/stop_button/register_stop_button.py +15 -0
  38. bec_widgets/widgets/{buttons/stop_button → stop_button}/stop_button.py +5 -12
  39. bec_widgets/widgets/stop_button/stop_button.pyproject +1 -0
  40. bec_widgets/widgets/stop_button/stop_button_plugin.py +57 -0
  41. bec_widgets/widgets/toggle/register_toggle_switch.py +15 -0
  42. bec_widgets/widgets/toggle/toggle.py +149 -0
  43. bec_widgets/widgets/toggle/toggle_switch.pyproject +1 -0
  44. bec_widgets/widgets/toggle/toggle_switch_plugin.py +54 -0
  45. {bec_widgets-0.79.3.dist-info → bec_widgets-0.82.0.dist-info}/METADATA +1 -4
  46. {bec_widgets-0.79.3.dist-info → bec_widgets-0.82.0.dist-info}/RECORD +66 -74
  47. docs/introduction/introduction.md +1 -1
  48. docs/user/getting_started/installation.md +2 -2
  49. pyproject.toml +1 -2
  50. tests/unit_tests/test_device_input_base.py +1 -1
  51. tests/unit_tests/test_device_input_widgets.py +2 -2
  52. tests/unit_tests/test_generate_cli_client.py +41 -17
  53. tests/unit_tests/test_plugin_utils.py +2 -3
  54. tests/unit_tests/test_stop_button.py +5 -2
  55. tests/unit_tests/test_toggle.py +38 -0
  56. bec_widgets/examples/motor_movement/__init__.py +0 -9
  57. bec_widgets/examples/motor_movement/motor_control_compilations.py +0 -250
  58. bec_widgets/examples/motor_movement/motor_controller.ui +0 -926
  59. bec_widgets/widgets/buttons/__init__.py +0 -1
  60. bec_widgets/widgets/buttons/color_button/color_button.py +0 -17
  61. bec_widgets/widgets/device_inputs/__init__.py +0 -2
  62. bec_widgets/widgets/device_inputs/device_combobox/device_combobox.pyproject +0 -4
  63. bec_widgets/widgets/device_inputs/device_combobox/launch_device_combobox.py +0 -11
  64. bec_widgets/widgets/device_inputs/device_line_edit/device_line_edit.pyproject +0 -4
  65. bec_widgets/widgets/device_inputs/device_line_edit/launch_device_line_edit.py +0 -11
  66. bec_widgets/widgets/motor_control/motor_control.py +0 -252
  67. bec_widgets/widgets/motor_control/motor_table/motor_table.py +0 -484
  68. bec_widgets/widgets/motor_control/motor_table/motor_table.ui +0 -113
  69. bec_widgets/widgets/motor_control/movement_absolute/__init__.py +0 -0
  70. bec_widgets/widgets/motor_control/movement_absolute/movement_absolute.py +0 -159
  71. bec_widgets/widgets/motor_control/movement_absolute/movement_absolute.ui +0 -149
  72. bec_widgets/widgets/motor_control/movement_relative/__init__.py +0 -0
  73. bec_widgets/widgets/motor_control/movement_relative/movement_relative.py +0 -230
  74. bec_widgets/widgets/motor_control/movement_relative/movement_relative.ui +0 -298
  75. bec_widgets/widgets/motor_control/selection/__init__.py +0 -0
  76. bec_widgets/widgets/motor_control/selection/selection.py +0 -110
  77. bec_widgets/widgets/motor_control/selection/selection.ui +0 -69
  78. tests/unit_tests/test_motor_control.py +0 -588
  79. /bec_widgets/widgets/{buttons/color_button → base_classes}/__init__.py +0 -0
  80. /bec_widgets/widgets/{buttons/stop_button → color_button}/__init__.py +0 -0
  81. /bec_widgets/widgets/{buttons/color_button → color_button}/assets/color_button.png +0 -0
  82. /bec_widgets/widgets/{buttons/color_button → color_button}/color_button.pyproject +0 -0
  83. /bec_widgets/widgets/{device_inputs/device_combobox → device_combobox}/__init__.py +0 -0
  84. /bec_widgets/widgets/{device_inputs/device_line_edit → device_line_edit}/__init__.py +0 -0
  85. /bec_widgets/widgets/{motor_control → stop_button}/__init__.py +0 -0
  86. /bec_widgets/widgets/{motor_control/motor_table → toggle}/__init__.py +0 -0
  87. {bec_widgets-0.79.3.dist-info → bec_widgets-0.82.0.dist-info}/WHEEL +0 -0
  88. {bec_widgets-0.79.3.dist-info → bec_widgets-0.82.0.dist-info}/entry_points.txt +0 -0
  89. {bec_widgets-0.79.3.dist-info → bec_widgets-0.82.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,159 +0,0 @@
1
- import os
2
-
3
- from qtpy import uic
4
- from qtpy.QtCore import Signal as pyqtSignal
5
- from qtpy.QtCore import Slot as pyqtSlot
6
- from qtpy.QtWidgets import QWidget
7
-
8
- from bec_widgets.utils import UILoader
9
- from bec_widgets.widgets.motor_control.motor_control import MotorControlErrors, MotorControlWidget
10
-
11
-
12
- class MotorControlAbsolute(MotorControlWidget):
13
- """
14
- Widget for controlling the motors to absolute coordinates.
15
-
16
- Signals:
17
- coordinates_signal (pyqtSignal(tuple)): Signal to emit the coordinates.
18
- Slots:
19
- change_motors (pyqtSlot): Slot to change the active motors.
20
- enable_motor_controls (pyqtSlot(bool)): Slot to enable/disable the motor controls.
21
- """
22
-
23
- coordinates_signal = pyqtSignal(tuple)
24
-
25
- def _load_ui(self):
26
- """Load the UI from the .ui file."""
27
- current_path = os.path.dirname(__file__)
28
- self.ui = UILoader().load_ui(os.path.join(current_path, "movement_absolute.ui"), self)
29
-
30
- def _init_ui(self):
31
- """Initialize the UI."""
32
-
33
- # Check if there are any motors connected
34
- if self.motor_x is None or self.motor_y is None:
35
- self.ui.motorControl_absolute.setEnabled(False)
36
- return
37
-
38
- # Move to absolute coordinates
39
- self.ui.pushButton_go_absolute.clicked.connect(
40
- lambda: self.move_motor_absolute(
41
- self.ui.spinBox_absolute_x.value(), self.ui.spinBox_absolute_y.value()
42
- )
43
- )
44
-
45
- self.ui.pushButton_set.clicked.connect(self.save_absolute_coordinates)
46
- self.ui.pushButton_save.clicked.connect(self.save_current_coordinates)
47
- self.ui.pushButton_stop.clicked.connect(self.motor_thread.stop_movement)
48
-
49
- # Enable/Disable GUI
50
- self.motor_thread.lock_gui.connect(self.enable_motor_controls)
51
-
52
- # Error messages
53
- self.motor_thread.motor_error.connect(
54
- lambda error: MotorControlErrors.display_error_message(error)
55
- )
56
-
57
- # Keyboard shortcuts
58
- self._init_keyboard_shortcuts()
59
-
60
- @pyqtSlot(dict)
61
- def on_config_update(self, config: dict) -> None:
62
- """Update config dict"""
63
- self.config = config
64
-
65
- # Get motor names
66
- self.motor_x, self.motor_y = (
67
- self.config["motor_control"]["motor_x"],
68
- self.config["motor_control"]["motor_y"],
69
- )
70
-
71
- # Update step precision
72
- self.precision = self.config["motor_control"]["precision"]
73
-
74
- self._init_ui()
75
-
76
- @pyqtSlot(bool)
77
- def enable_motor_controls(self, enable: bool) -> None:
78
- """
79
- Enable or disable the motor controls.
80
- Args:
81
- enable(bool): True to enable, False to disable.
82
- """
83
-
84
- # Disable or enable all controls within the motorControl_absolute group box
85
- for widget in self.ui.motorControl_absolute.findChildren(QWidget):
86
- widget.setEnabled(enable)
87
-
88
- # Enable the pushButton_stop if the motor is moving
89
- self.ui.pushButton_stop.setEnabled(True)
90
-
91
- @pyqtSlot(str, str)
92
- def change_motors(self, motor_x: str, motor_y: str):
93
- """
94
- Change the active motors and update config.
95
- Can be connected to the selected_motors_signal from MotorControlSelection.
96
- Args:
97
- motor_x(str): New motor X to be controlled.
98
- motor_y(str): New motor Y to be controlled.
99
- """
100
- self.motor_x = motor_x
101
- self.motor_y = motor_y
102
- self.config["motor_control"]["motor_x"] = motor_x
103
- self.config["motor_control"]["motor_y"] = motor_y
104
-
105
- @pyqtSlot(int)
106
- def set_precision(self, precision: int) -> None:
107
- """
108
- Set the precision of the coordinates.
109
- Args:
110
- precision(int): Precision of the coordinates.
111
- """
112
- self.precision = precision
113
- self.config["motor_control"]["precision"] = precision
114
- self.ui.spinBox_absolute_x.setDecimals(precision)
115
- self.ui.spinBox_absolute_y.setDecimals(precision)
116
-
117
- def move_motor_absolute(self, x: float, y: float) -> None:
118
- """
119
- Move the motor to the target coordinates.
120
- Args:
121
- x(float): Target x coordinate.
122
- y(float): Target y coordinate.
123
- """
124
- # self._enable_motor_controls(False)
125
- target_coordinates = (x, y)
126
- self.motor_thread.move_absolute(self.motor_x, self.motor_y, target_coordinates)
127
- if self.ui.checkBox_save_with_go.isChecked():
128
- self.save_absolute_coordinates()
129
-
130
- def _init_keyboard_shortcuts(self):
131
- """Initialize the keyboard shortcuts."""
132
- # Go absolute button
133
- self.ui.pushButton_go_absolute.setShortcut("Ctrl+G")
134
- self.ui.pushButton_go_absolute.setToolTip("Ctrl+G")
135
-
136
- # Set absolute coordinates
137
- self.ui.pushButton_set.setShortcut("Ctrl+D")
138
- self.ui.pushButton_set.setToolTip("Ctrl+D")
139
-
140
- # Save Current coordinates
141
- self.ui.pushButton_save.setShortcut("Ctrl+S")
142
- self.ui.pushButton_save.setToolTip("Ctrl+S")
143
-
144
- # Stop Button
145
- self.ui.pushButton_stop.setShortcut("Ctrl+X")
146
- self.ui.pushButton_stop.setToolTip("Ctrl+X")
147
-
148
- def save_absolute_coordinates(self):
149
- """Emit the setup coordinates from the spinboxes"""
150
-
151
- x, y = round(self.ui.spinBox_absolute_x.value(), self.precision), round(
152
- self.ui.spinBox_absolute_y.value(), self.precision
153
- )
154
- self.coordinates_signal.emit((x, y))
155
-
156
- def save_current_coordinates(self):
157
- """Emit the current coordinates from the motor thread"""
158
- x, y = self.motor_thread.get_coordinates(self.motor_x, self.motor_y)
159
- self.coordinates_signal.emit((round(x, self.precision), round(y, self.precision)))
@@ -1,149 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <ui version="4.0">
3
- <class>Form</class>
4
- <widget class="QWidget" name="Form">
5
- <property name="geometry">
6
- <rect>
7
- <x>0</x>
8
- <y>0</y>
9
- <width>285</width>
10
- <height>220</height>
11
- </rect>
12
- </property>
13
- <property name="minimumSize">
14
- <size>
15
- <width>285</width>
16
- <height>220</height>
17
- </size>
18
- </property>
19
- <property name="maximumSize">
20
- <size>
21
- <width>285</width>
22
- <height>220</height>
23
- </size>
24
- </property>
25
- <property name="windowTitle">
26
- <string>Move Movement Absolute</string>
27
- </property>
28
- <layout class="QVBoxLayout" name="verticalLayout_2">
29
- <item>
30
- <widget class="QGroupBox" name="motorControl_absolute">
31
- <property name="minimumSize">
32
- <size>
33
- <width>261</width>
34
- <height>195</height>
35
- </size>
36
- </property>
37
- <property name="maximumSize">
38
- <size>
39
- <width>261</width>
40
- <height>195</height>
41
- </size>
42
- </property>
43
- <property name="title">
44
- <string>Move Movement Absolute</string>
45
- </property>
46
- <layout class="QVBoxLayout" name="verticalLayout">
47
- <item>
48
- <widget class="QCheckBox" name="checkBox_save_with_go">
49
- <property name="text">
50
- <string>Save position with Go</string>
51
- </property>
52
- </widget>
53
- </item>
54
- <item>
55
- <layout class="QGridLayout" name="gridLayout_3">
56
- <item row="1" column="1">
57
- <widget class="QDoubleSpinBox" name="spinBox_absolute_y">
58
- <property name="alignment">
59
- <set>Qt::AlignCenter</set>
60
- </property>
61
- <property name="minimum">
62
- <double>-500.000000000000000</double>
63
- </property>
64
- <property name="maximum">
65
- <double>500.000000000000000</double>
66
- </property>
67
- <property name="singleStep">
68
- <double>0.100000000000000</double>
69
- </property>
70
- </widget>
71
- </item>
72
- <item row="1" column="0">
73
- <widget class="QDoubleSpinBox" name="spinBox_absolute_x">
74
- <property name="alignment">
75
- <set>Qt::AlignCenter</set>
76
- </property>
77
- <property name="minimum">
78
- <double>-500.000000000000000</double>
79
- </property>
80
- <property name="maximum">
81
- <double>500.000000000000000</double>
82
- </property>
83
- <property name="singleStep">
84
- <double>0.100000000000000</double>
85
- </property>
86
- </widget>
87
- </item>
88
- <item row="0" column="1">
89
- <widget class="QLabel" name="label_7">
90
- <property name="text">
91
- <string>Y</string>
92
- </property>
93
- <property name="alignment">
94
- <set>Qt::AlignCenter</set>
95
- </property>
96
- </widget>
97
- </item>
98
- <item row="0" column="0">
99
- <widget class="QLabel" name="label_6">
100
- <property name="text">
101
- <string>X</string>
102
- </property>
103
- <property name="alignment">
104
- <set>Qt::AlignCenter</set>
105
- </property>
106
- </widget>
107
- </item>
108
- </layout>
109
- </item>
110
- <item>
111
- <layout class="QHBoxLayout" name="horizontalLayout_2">
112
- <item>
113
- <widget class="QPushButton" name="pushButton_save">
114
- <property name="text">
115
- <string>Save</string>
116
- </property>
117
- </widget>
118
- </item>
119
- <item>
120
- <widget class="QPushButton" name="pushButton_set">
121
- <property name="text">
122
- <string>Set</string>
123
- </property>
124
- </widget>
125
- </item>
126
- <item>
127
- <widget class="QPushButton" name="pushButton_go_absolute">
128
- <property name="text">
129
- <string>Go</string>
130
- </property>
131
- </widget>
132
- </item>
133
- </layout>
134
- </item>
135
- <item>
136
- <widget class="QPushButton" name="pushButton_stop">
137
- <property name="text">
138
- <string>Stop Movement</string>
139
- </property>
140
- </widget>
141
- </item>
142
- </layout>
143
- </widget>
144
- </item>
145
- </layout>
146
- </widget>
147
- <resources/>
148
- <connections/>
149
- </ui>
@@ -1,230 +0,0 @@
1
- import os
2
-
3
- from qtpy import uic
4
- from qtpy.QtCore import Qt
5
- from qtpy.QtCore import Signal as pyqtSignal
6
- from qtpy.QtCore import Slot as pyqtSlot
7
- from qtpy.QtGui import QKeySequence
8
- from qtpy.QtWidgets import QDoubleSpinBox, QShortcut, QWidget
9
-
10
- from bec_widgets.utils import UILoader
11
- from bec_widgets.widgets.motor_control.motor_control import MotorControlWidget
12
-
13
-
14
- class MotorControlRelative(MotorControlWidget):
15
- """
16
- Widget for controlling the motors to relative coordinates.
17
-
18
- Signals:
19
- precision_signal (pyqtSignal): Signal to emit the precision of the coordinates.
20
- Slots:
21
- change_motors (pyqtSlot(str,str)): Slot to change the active motors.
22
- enable_motor_controls (pyqtSlot): Slot to enable/disable the motor controls.
23
- """
24
-
25
- precision_signal = pyqtSignal(int)
26
-
27
- def _load_ui(self):
28
- """Load the UI from the .ui file."""
29
- # Loading UI
30
- current_path = os.path.dirname(__file__)
31
- self.ui = UILoader().load_ui(os.path.join(current_path, "movement_relative.ui"), self)
32
-
33
- def _init_ui(self):
34
- """Initialize the UI."""
35
- self._init_ui_motor_control()
36
- self._init_keyboard_shortcuts()
37
-
38
- @pyqtSlot(dict)
39
- def on_config_update(self, config: dict) -> None:
40
- """
41
- Update config dict
42
- Args:
43
- config(dict): New config dict
44
- """
45
- self.config = config
46
-
47
- # Get motor names
48
- self.motor_x, self.motor_y = (
49
- self.config["motor_control"]["motor_x"],
50
- self.config["motor_control"]["motor_y"],
51
- )
52
-
53
- # Update step precision
54
- self.precision = self.config["motor_control"]["precision"]
55
- self.ui.spinBox_precision.setValue(self.precision)
56
-
57
- # Update step sizes
58
- self.ui.spinBox_step_x.setValue(self.config["motor_control"]["step_size_x"])
59
- self.ui.spinBox_step_y.setValue(self.config["motor_control"]["step_size_y"])
60
-
61
- # Checkboxes for keyboard shortcuts and x/y step size link
62
- self.ui.checkBox_same_xy.setChecked(self.config["motor_control"]["step_x_y_same"])
63
- self.ui.checkBox_enableArrows.setChecked(self.config["motor_control"]["move_with_arrows"])
64
-
65
- self._init_ui()
66
-
67
- def _init_ui_motor_control(self) -> None:
68
- """Initialize the motor control elements"""
69
-
70
- # Connect checkbox and spinBoxes
71
- self.ui.checkBox_same_xy.stateChanged.connect(self._sync_step_sizes)
72
- self.ui.spinBox_step_x.valueChanged.connect(self._update_step_size_x)
73
- self.ui.spinBox_step_y.valueChanged.connect(self._update_step_size_y)
74
-
75
- self.ui.toolButton_right.clicked.connect(
76
- lambda: self.move_motor_relative(self.motor_x, "x", 1)
77
- )
78
- self.ui.toolButton_left.clicked.connect(
79
- lambda: self.move_motor_relative(self.motor_x, "x", -1)
80
- )
81
- self.ui.toolButton_up.clicked.connect(
82
- lambda: self.move_motor_relative(self.motor_y, "y", 1)
83
- )
84
- self.ui.toolButton_down.clicked.connect(
85
- lambda: self.move_motor_relative(self.motor_y, "y", -1)
86
- )
87
-
88
- # Switch between key shortcuts active
89
- self.ui.checkBox_enableArrows.stateChanged.connect(self._update_arrow_key_shortcuts)
90
- self._update_arrow_key_shortcuts()
91
-
92
- # Enable/Disable GUI
93
- self.motor_thread.lock_gui.connect(self.enable_motor_controls)
94
-
95
- # Precision update
96
- self.ui.spinBox_precision.valueChanged.connect(lambda x: self._update_precision(x))
97
-
98
- # Error messages
99
- self.motor_thread.motor_error.connect(
100
- lambda error: MotorControlErrors.display_error_message(error)
101
- )
102
-
103
- # Stop Button
104
- self.ui.pushButton_stop.clicked.connect(self.motor_thread.stop_movement)
105
-
106
- def _init_keyboard_shortcuts(self) -> None:
107
- """Initialize the keyboard shortcuts"""
108
-
109
- # Increase/decrease step size for X motor
110
- increase_x_shortcut = QShortcut(QKeySequence("Ctrl+A"), self)
111
- decrease_x_shortcut = QShortcut(QKeySequence("Ctrl+Z"), self)
112
- increase_x_shortcut.activated.connect(
113
- lambda: self._change_step_size(self.ui.spinBox_step_x, 2)
114
- )
115
- decrease_x_shortcut.activated.connect(
116
- lambda: self._change_step_size(self.ui.spinBox_step_x, 0.5)
117
- )
118
- self.ui.spinBox_step_x.setToolTip("Increase step size: Ctrl+A\nDecrease step size: Ctrl+Z")
119
-
120
- # Increase/decrease step size for Y motor
121
- increase_y_shortcut = QShortcut(QKeySequence("Alt+A"), self)
122
- decrease_y_shortcut = QShortcut(QKeySequence("Alt+Z"), self)
123
- increase_y_shortcut.activated.connect(
124
- lambda: self._change_step_size(self.ui.spinBox_step_y, 2)
125
- )
126
- decrease_y_shortcut.activated.connect(
127
- lambda: self._change_step_size(self.ui.spinBox_step_y, 0.5)
128
- )
129
- self.ui.spinBox_step_y.setToolTip("Increase step size: Alt+A\nDecrease step size: Alt+Z")
130
-
131
- # Stop Button
132
- self.ui.pushButton_stop.setShortcut("Ctrl+X")
133
- self.ui.pushButton_stop.setToolTip("Ctrl+X")
134
-
135
- def _update_arrow_key_shortcuts(self) -> None:
136
- """Update the arrow key shortcuts based on the checkbox state."""
137
- if self.ui.checkBox_enableArrows.isChecked():
138
- # Set the arrow key shortcuts for motor movement
139
- self.ui.toolButton_right.setShortcut(Qt.Key_Right)
140
- self.ui.toolButton_left.setShortcut(Qt.Key_Left)
141
- self.ui.toolButton_up.setShortcut(Qt.Key_Up)
142
- self.ui.toolButton_down.setShortcut(Qt.Key_Down)
143
- else:
144
- # Clear the shortcuts
145
- self.ui.toolButton_right.setShortcut("")
146
- self.ui.toolButton_left.setShortcut("")
147
- self.ui.toolButton_up.setShortcut("")
148
- self.ui.toolButton_down.setShortcut("")
149
-
150
- def _update_precision(self, precision: int) -> None:
151
- """
152
- Update the precision of the coordinates.
153
- Args:
154
- precision(int): Precision of the coordinates.
155
- """
156
- self.ui.spinBox_step_x.setDecimals(precision)
157
- self.ui.spinBox_step_y.setDecimals(precision)
158
- self.precision_signal.emit(precision)
159
-
160
- def _change_step_size(self, spinBox: QDoubleSpinBox, factor: float) -> None:
161
- """
162
- Change the step size of the spinbox.
163
- Args:
164
- spinBox(QDoubleSpinBox): Spinbox to change the step size.
165
- factor(float): Factor to change the step size.
166
- """
167
- old_step = spinBox.value()
168
- new_step = old_step * factor
169
- spinBox.setValue(new_step)
170
-
171
- def _sync_step_sizes(self):
172
- """Sync step sizes based on checkbox state."""
173
- if self.ui.checkBox_same_xy.isChecked():
174
- value = self.ui.spinBox_step_x.value()
175
- self.ui.spinBox_step_y.setValue(value)
176
-
177
- def _update_step_size_x(self):
178
- """Update step size for x if checkbox is checked."""
179
- if self.ui.checkBox_same_xy.isChecked():
180
- value = self.ui.spinBox_step_x.value()
181
- self.ui.spinBox_step_y.setValue(value)
182
-
183
- def _update_step_size_y(self):
184
- """Update step size for y if checkbox is checked."""
185
- if self.ui.checkBox_same_xy.isChecked():
186
- value = self.ui.spinBox_step_y.value()
187
- self.ui.spinBox_step_x.setValue(value)
188
-
189
- @pyqtSlot(str, str)
190
- def change_motors(self, motor_x: str, motor_y: str):
191
- """
192
- Change the active motors and update config.
193
- Can be connected to the selected_motors_signal from MotorControlSelection.
194
- Args:
195
- motor_x(str): New motor X to be controlled.
196
- motor_y(str): New motor Y to be controlled.
197
- """
198
- self.motor_x = motor_x
199
- self.motor_y = motor_y
200
- self.config["motor_control"]["motor_x"] = motor_x
201
- self.config["motor_control"]["motor_y"] = motor_y
202
-
203
- @pyqtSlot(bool)
204
- def enable_motor_controls(self, disable: bool) -> None:
205
- """
206
- Enable or disable the motor controls.
207
- Args:
208
- disable(bool): True to disable, False to enable.
209
- """
210
-
211
- # Disable or enable all controls within the motorControl_absolute group box
212
- for widget in self.ui.motorControl.findChildren(QWidget):
213
- widget.setEnabled(disable)
214
-
215
- # Enable the pushButton_stop if the motor is moving
216
- self.ui.pushButton_stop.setEnabled(True)
217
-
218
- def move_motor_relative(self, motor, axis: str, direction: int) -> None:
219
- """
220
- Move the motor relative to the current position.
221
- Args:
222
- motor: Motor to move.
223
- axis(str): Axis to move.
224
- direction(int): Direction to move. 1 for positive, -1 for negative.
225
- """
226
- if axis == "x":
227
- step = direction * self.ui.spinBox_step_x.value()
228
- elif axis == "y":
229
- step = direction * self.ui.spinBox_step_y.value()
230
- self.motor_thread.move_relative(motor, step)