mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
fix(scan_group_box): added row counter based on widgets
This commit is contained in:
@ -121,7 +121,7 @@ class ScanControl(BECConnector, QWidget):
|
|||||||
if len(self.arg_group["arg_inputs"]) > 0:
|
if len(self.arg_group["arg_inputs"]) > 0:
|
||||||
self.button_add_bundle.setEnabled(True)
|
self.button_add_bundle.setEnabled(True)
|
||||||
self.button_remove_bundle.setEnabled(True)
|
self.button_remove_bundle.setEnabled(True)
|
||||||
self.add_arg_group(self.arg_group) # TODO here class method for arg box
|
self.add_arg_group(self.arg_group)
|
||||||
if len(self.kwarg_groups) > 0:
|
if len(self.kwarg_groups) > 0:
|
||||||
self.add_kwargs_boxes(self.kwarg_groups)
|
self.add_kwargs_boxes(self.kwarg_groups)
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@ from qtpy.QtWidgets import (
|
|||||||
QComboBox,
|
QComboBox,
|
||||||
QDoubleSpinBox,
|
QDoubleSpinBox,
|
||||||
QGridLayout,
|
QGridLayout,
|
||||||
|
QGroupBox,
|
||||||
QLabel,
|
QLabel,
|
||||||
QLineEdit,
|
QLineEdit,
|
||||||
QSpinBox,
|
QSpinBox,
|
||||||
)
|
)
|
||||||
from qtpy.QtWidgets import QGroupBox
|
|
||||||
|
|
||||||
from bec_widgets.utils.widget_io import WidgetIO
|
from bec_widgets.utils.widget_io import WidgetIO
|
||||||
from bec_widgets.widgets.device_inputs import DeviceLineEdit
|
from bec_widgets.widgets.device_inputs import DeviceLineEdit
|
||||||
@ -170,8 +170,8 @@ class ScanGroupBox(QGroupBox):
|
|||||||
if self.box_type != "args":
|
if self.box_type != "args":
|
||||||
return
|
return
|
||||||
arg_min = self.config.get("min", None)
|
arg_min = self.config.get("min", None)
|
||||||
row = self.layout.rowCount()
|
row = self.count_arg_rows()
|
||||||
if arg_min is not None and row <= arg_min + 1:
|
if arg_min is not None and row <= arg_min:
|
||||||
return
|
return
|
||||||
|
|
||||||
for widget in self.widgets[-len(self.inputs) :]:
|
for widget in self.widgets[-len(self.inputs) :]:
|
||||||
@ -183,10 +183,8 @@ class ScanGroupBox(QGroupBox):
|
|||||||
Returns the parameters from the widgets in the scan control layout formated to run scan from BEC.
|
Returns the parameters from the widgets in the scan control layout formated to run scan from BEC.
|
||||||
"""
|
"""
|
||||||
if self.box_type == "args":
|
if self.box_type == "args":
|
||||||
print(self._get_arg_parameterts())
|
|
||||||
return self._get_arg_parameterts()
|
return self._get_arg_parameterts()
|
||||||
elif self.box_type == "kwargs":
|
elif self.box_type == "kwargs":
|
||||||
print(self._get_kwarg_parameters())
|
|
||||||
return self._get_kwarg_parameters()
|
return self._get_kwarg_parameters()
|
||||||
|
|
||||||
def _get_arg_parameterts(self):
|
def _get_arg_parameterts(self):
|
||||||
@ -211,3 +209,15 @@ class ScanGroupBox(QGroupBox):
|
|||||||
value = WidgetIO.get_value(widget)
|
value = WidgetIO.get_value(widget)
|
||||||
kwargs[widget.arg_name] = value
|
kwargs[widget.arg_name] = value
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
def count_arg_rows(self):
|
||||||
|
widget_rows = 0
|
||||||
|
for row in range(self.layout.rowCount()):
|
||||||
|
for col in range(self.layout.columnCount()):
|
||||||
|
item = self.layout.itemAtPosition(row, col)
|
||||||
|
if item is not None:
|
||||||
|
widget = item.widget()
|
||||||
|
if widget is not None:
|
||||||
|
if isinstance(widget, DeviceLineEdit):
|
||||||
|
widget_rows += 1
|
||||||
|
return widget_rows
|
||||||
|
@ -2,15 +2,13 @@
|
|||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from bec_lib.messages import AvailableResourceMessage
|
from bec_lib.messages import AvailableResourceMessage
|
||||||
|
|
||||||
from bec_widgets.utils.widget_io import WidgetIO
|
from bec_widgets.utils.widget_io import WidgetIO
|
||||||
from bec_widgets.widgets.scan_control import ScanControl
|
from bec_widgets.widgets.scan_control import ScanControl
|
||||||
|
|
||||||
|
|
||||||
from .client_mocks import mocked_client
|
from .client_mocks import mocked_client
|
||||||
|
|
||||||
|
|
||||||
available_scans_message = AvailableResourceMessage(
|
available_scans_message = AvailableResourceMessage(
|
||||||
resource={
|
resource={
|
||||||
"line_scan": {
|
"line_scan": {
|
||||||
|
Reference in New Issue
Block a user