# DialogHeight.py -- Pamhyr # Copyright (C) 2023-2024 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 -*- from View.Tools.PamhyrWindow import PamhyrDialog from PyQt5.QtGui import ( QKeySequence, ) from PyQt5.QtCore import ( Qt, QVariant, QAbstractTableModel, ) from PyQt5.QtWidgets import ( QDialogButtonBox, QComboBox, QUndoStack, QShortcut, QDoubleSpinBox, QCheckBox, QLabel ) class HeightDialog(PamhyrDialog): _pamhyr_ui = "InitialConditions_Dialog_Generator_Height" _pamhyr_name = "Height" def __init__(self, trad=None, parent=None): super(HeightDialog, self).__init__( title=trad[self._pamhyr_name], options=[], trad=trad, parent=parent ) self.value = [None, None, None] self.option = None self.find(QCheckBox, "checkBox").clicked.connect( self.enable_discharge ) def enable_discharge(self): cb = self.find(QCheckBox, "checkBox") dsb = self.find(QDoubleSpinBox, "doubleSpinBox_3") l = self.find(QLabel, "label_3") dsb.setEnabled(cb.isChecked()) l.setEnabled(cb.isChecked()) def accept(self): self.value[0] = self.find(QDoubleSpinBox, "doubleSpinBox_1").value() self.value[1] = self.find(QDoubleSpinBox, "doubleSpinBox_2").value() self.option = self.find(QCheckBox, "checkBox").isChecked() if self.option: self.value[2] = self.find(QDoubleSpinBox, "doubleSpinBox_3").value() else: self.value[2] = None super().accept() def reject(self): self.close()