From c2d28b011015757802e55d931b7b2eb071c2d1c8 Mon Sep 17 00:00:00 2001 From: Dylan Jeannin Date: Thu, 16 Apr 2026 16:44:14 +0200 Subject: [PATCH] can use '.' caracter and not only ',' in Shift Geometry window --- src/View/Geometry/ShiftDialog.py | 33 ++++++++++++++++++++-- src/View/Tools/FlexibleDoubleSpinBox.py | 37 +++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/View/Tools/FlexibleDoubleSpinBox.py diff --git a/src/View/Geometry/ShiftDialog.py b/src/View/Geometry/ShiftDialog.py index 38744429..85ff029b 100644 --- a/src/View/Geometry/ShiftDialog.py +++ b/src/View/Geometry/ShiftDialog.py @@ -17,7 +17,8 @@ # -*- coding: utf-8 -*- from View.Tools.PamhyrWindow import PamhyrDialog - +from PyQt5.QtWidgets import QDoubleSpinBox +from View.Tools.FlexibleDoubleSpinBox import FlexibleDoubleSpinBox class ShiftDialog(PamhyrDialog): _pamhyr_ui = "GeometryReachShift" @@ -30,9 +31,37 @@ class ShiftDialog(PamhyrDialog): options=[], parent=parent ) - + + self._replace_spinboxes() self._init_default_values() + def _replace_spinboxes(self): + for name in ["doubleSpinBox_X", "doubleSpinBox_Y", "doubleSpinBox_Z"]: + old = self.find(QDoubleSpinBox, name) + + if old is None: + continue + + new = FlexibleDoubleSpinBox(old.parent()) + new.setObjectName(old.objectName()) + + # Copier propriétés utiles + new.setDecimals(old.decimals()) + new.setMinimum(old.minimum()) + new.setMaximum(old.maximum()) + new.setSingleStep(old.singleStep()) + new.setValue(old.value()) + new.setGeometry(old.geometry()) + + # Remplacement dans layout si présent + layout = old.parent().layout() + if layout is not None: + layout.replaceWidget(old, new) + + old.hide() + old.setParent(None) + old.deleteLater() + def _init_default_values(self): self._dx = 0.0 self._dy = 0.0 diff --git a/src/View/Tools/FlexibleDoubleSpinBox.py b/src/View/Tools/FlexibleDoubleSpinBox.py new file mode 100644 index 00000000..34332bef --- /dev/null +++ b/src/View/Tools/FlexibleDoubleSpinBox.py @@ -0,0 +1,37 @@ +# PamhyrWindow.py -- Pamhyr +# Copyright (C) 2023-2025 INRAE +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# -*- coding: utf-8 -*- + +import os +import logging + +from PyQt5.QtWidgets import QDoubleSpinBox + + +class FlexibleDoubleSpinBox(QDoubleSpinBox): + + def keyPressEvent(self, event): + if event.text() == ".": + # Simule une virgule à la place du point + event = type(event)( + event.type(), + event.key(), + event.modifiers(), + "," + ) + + super().keyPressEvent(event) \ No newline at end of file