Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Working units with validator
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoneiESS committed Oct 18, 2023
1 parent f5c7407 commit 674e553
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ui/transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
)
Expand Down

0 comments on commit 674e553

Please sign in to comment.