diff --git a/bec_widgets/examples/motor_movement/motor_example.py b/bec_widgets/examples/motor_movement/motor_example.py index a8d45599..a61a96a9 100644 --- a/bec_widgets/examples/motor_movement/motor_example.py +++ b/bec_widgets/examples/motor_movement/motor_example.py @@ -254,10 +254,14 @@ class MotorApp(QWidget): def init_ui_motor_control(self) -> None: """Initialize the motor control elements""" - # Connect checkbox and spinBoxes - self.checkBox_same_xy.stateChanged.connect(self.sync_step_sizes) - self.spinBox_step_x.valueChanged.connect(self.update_step_size_x) - self.spinBox_step_y.valueChanged.connect(self.update_step_size_y) + # Connect CheckBox stateChanged signal to sync function + self.checkBox_same_xy.stateChanged.connect( + lambda: self.sync_step_sizes(self.spinBox_step_x, self.spinBox_step_y) + ) + + # TODO remove + # self.spinBox_step_x.valueChanged.connect(self.update_step_size_x) + # self.spinBox_step_y.valueChanged.connect(self.update_step_size_y) self.toolButton_right.clicked.connect( lambda: self.move_motor_relative(self.motor_x, "x", 1) @@ -607,25 +611,10 @@ class MotorApp(QWidget): new_step = old_step * factor spinBox.setValue(new_step) - # TODO generalise the following functions: - - def sync_step_sizes(self): - """Sync step sizes based on checkbox state.""" + def sync_step_sizes(self, spinBox1, spinBox2): if self.checkBox_same_xy.isChecked(): - value = self.spinBox_step_x.value() - self.spinBox_step_y.setValue(value) - - def update_step_size_x(self): - """Update step size for x if checkbox is checked.""" - if self.checkBox_same_xy.isChecked(): - value = self.spinBox_step_x.value() - self.spinBox_step_y.setValue(value) - - def update_step_size_y(self): - """Update step size for y if checkbox is checked.""" - if self.checkBox_same_xy.isChecked(): - value = self.spinBox_step_y.value() - self.spinBox_step_x.setValue(value) + value = spinBox1.value() + spinBox2.setValue(value) @staticmethod def param_changed(ui_element):