From 674e55398ea1b36e92fb1ee777f0884518d41260 Mon Sep 17 00:00:00 2001 From: George O'Neill Date: Wed, 18 Oct 2023 13:59:45 +0200 Subject: [PATCH] Working units with validator --- ui/transformation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/transformation.py b/ui/transformation.py index 986d3b200..1546a3957 100644 --- a/ui/transformation.py +++ b/ui/transformation.py @@ -19,6 +19,7 @@ from nexus_constructor.field_widget import FieldWidget from nexus_constructor.ui_utils import validate_line_edit from nexus_constructor.validators import UnitValidator +from nexus_constructor.unit_utils import METRES if TYPE_CHECKING: from nexus_constructor.transformation_view import EditTransformation @@ -104,13 +105,14 @@ def setup_offset_layout(self, transformation): self.main_layout.addWidget(self.offset_label) self._set_up_vector_box_offset(transformation) self.offset_units_line_edit = QLineEdit() - self.offset_unit_validator = UnitValidator() + self.offset_unit_validator = UnitValidator(expected_dimensionality=METRES) self.offset_units_line_edit.setValidator(self.offset_unit_validator) self.offset_units_line_edit.setMinimumWidth(20) offset_unit_size_policy = QSizePolicy() offset_unit_size_policy.setHorizontalPolicy(QSizePolicy.Preferred) offset_unit_size_policy.setHorizontalStretch(1) self.offset_units_line_edit.setSizePolicy(offset_unit_size_policy) + self.offset_units_line_edit.setText("m") self.offset_unit_validator.is_valid.connect( partial(validate_line_edit, self.offset_units_line_edit) )