0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-14 11:41:49 +02:00

refactor: scan_control.py extraction of args separated

This commit is contained in:
wyzula-jan
2023-11-07 19:19:59 +01:00
parent 2e42ba174f
commit 63f23cf78e

View File

@ -338,19 +338,18 @@ class ScanControl(QWidget):
kwargs[key] = value kwargs[key] = value
return kwargs return kwargs
def run_scan(self): def extract_args_from_table(self, table: QTableWidget) -> list:
# Extract kwargs for the scan """
kwargs = { Extracts the arguments from the given table widget.
k.lower(): v Args:
for k, v in self.extract_kwargs_from_grid_row(self.kwargs_layout, 1).items() table(QTableWidget): Table widget from which to extract the arguments
} """
# Extract args from the table # Extract args from the table
args = [] args = []
for row in range(self.args_table.rowCount()): for row in range(table.rowCount()):
row_args = [] row_args = []
for column in range(self.args_table.columnCount()): for column in range(table.columnCount()):
widget = self.args_table.cellWidget(row, column) widget = table.cellWidget(row, column)
if widget: if widget:
# Extract the value from the widget # Extract the value from the widget
if isinstance(widget, QLineEdit): if isinstance(widget, QLineEdit):
@ -364,6 +363,17 @@ class ScanControl(QWidget):
value = None # You can decide how to handle other widget types value = None # You can decide how to handle other widget types
row_args.append(value) row_args.append(value)
args.extend(row_args) args.extend(row_args)
return args
def run_scan(self):
# Extract kwargs for the scan
kwargs = {
k.lower(): v
for k, v in self.extract_kwargs_from_grid_row(self.kwargs_layout, 1).items()
}
# Extract args from the table
args = self.extract_args_from_table()
# Convert args to lowercase if they are strings # Convert args to lowercase if they are strings
args = [arg.lower() if isinstance(arg, str) else arg for arg in args] args = [arg.lower() if isinstance(arg, str) else arg for arg in args]