mirror of https://gitlab.com/pamhyr/pamhyr2
can use '.' caracter and not only ',' in Shift Geometry window
parent
23361d142e
commit
c2d28b0110
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- 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)
|
||||
Loading…
Reference in New Issue