mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
refactor: sync_step_sizes generalised to one function
This commit is contained in:
@ -254,10 +254,14 @@ class MotorApp(QWidget):
|
|||||||
def init_ui_motor_control(self) -> None:
|
def init_ui_motor_control(self) -> None:
|
||||||
"""Initialize the motor control elements"""
|
"""Initialize the motor control elements"""
|
||||||
|
|
||||||
# Connect checkbox and spinBoxes
|
# Connect CheckBox stateChanged signal to sync function
|
||||||
self.checkBox_same_xy.stateChanged.connect(self.sync_step_sizes)
|
self.checkBox_same_xy.stateChanged.connect(
|
||||||
self.spinBox_step_x.valueChanged.connect(self.update_step_size_x)
|
lambda: self.sync_step_sizes(self.spinBox_step_x, self.spinBox_step_y)
|
||||||
self.spinBox_step_y.valueChanged.connect(self.update_step_size_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(
|
self.toolButton_right.clicked.connect(
|
||||||
lambda: self.move_motor_relative(self.motor_x, "x", 1)
|
lambda: self.move_motor_relative(self.motor_x, "x", 1)
|
||||||
@ -607,25 +611,10 @@ class MotorApp(QWidget):
|
|||||||
new_step = old_step * factor
|
new_step = old_step * factor
|
||||||
spinBox.setValue(new_step)
|
spinBox.setValue(new_step)
|
||||||
|
|
||||||
# TODO generalise the following functions:
|
def sync_step_sizes(self, spinBox1, spinBox2):
|
||||||
|
|
||||||
def sync_step_sizes(self):
|
|
||||||
"""Sync step sizes based on checkbox state."""
|
|
||||||
if self.checkBox_same_xy.isChecked():
|
if self.checkBox_same_xy.isChecked():
|
||||||
value = self.spinBox_step_x.value()
|
value = spinBox1.value()
|
||||||
self.spinBox_step_y.setValue(value)
|
spinBox2.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)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def param_changed(ui_element):
|
def param_changed(ui_element):
|
||||||
|
Reference in New Issue
Block a user