An error occurred while loading the file. Please try again.
-
Le Roux Erwan authored
[SCM][HYPERCUBE] normalize gev trend_strength with distance between years. update test to check this distance.
661bfe29
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Window.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 <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
from Model.Study import Study
from View.Tools.PamhyrWindow import PamhyrDialog
from PyQt5.QtCore import QCoreApplication
from PyQt5.QtGui import (
QFont, QColor
)
from PyQt5.QtWidgets import (
QRadioButton, QLabel, QDateTimeEdit,
QTextEdit, QPushButton,
)
_translate = QCoreApplication.translate
class NewStudyWindow(PamhyrDialog):
_pamhyr_ui = "NewStudy"
_pamhyr_name = "Edit/New Study"
def __init__(self, study=None, config=None, parent=None):
if study is not None:
name = (
_translate("Study", "Edit study")
+ f" - {study.name}"
)
else:
name = _translate("Study", "New study")
super(NewStudyWindow, self).__init__(
title=name,
study=study,
config=config,
options=[],
parent=parent
)
if self._study is not None:
self.set_line_edit_text("lineEdit_name", self._study.name)
self.set_text_edit_text(
"textEdit_description", self._study.description
)
self.set_datetime_edit("dateTimeEdit_date", self._study.date)
self.find(QLabel, "label_creation_date_data").setText(
self._study.creation_date.isoformat(sep=" ")
)
self.find(QLabel, "label_last_modification_data").setText(
self._study.last_save_date.isoformat(sep=" ")
)
if self._study.time_system == "date":
self.set_radio_button("radioButton_date", True)
self.find(QLabel, "label_date").setEnabled(True)
self.find(QDateTimeEdit, "dateTimeEdit_date").setEnabled(True)
self.connection()
def connection(self):
time = self.find(QRadioButton, "radioButton_time")
date = self.find(QRadioButton, "radioButton_date")
time.toggled.connect(self.set_time)
date.toggled.connect(self.set_date)
self._desc = self.find(QTextEdit, "textEdit_description")
self._bold = self.find(QPushButton, "pushButton_bold")
self._italic = self.find(QPushButton, "pushButton_italic")
self._underline = self.find(QPushButton, "pushButton_underline")
self._highlight = self.find(QPushButton, "pushButton_highlight")
self._bold.clicked.connect(
lambda x: self._desc.setFontWeight(
QFont.Bold if x else QFont.Normal
)
)
self._italic.clicked.connect(self._desc.setFontItalic)
self._underline.clicked.connect(self._desc.setFontUnderline)
self._highlight.clicked.connect(
lambda x: self._desc.setTextBackgroundColor(
QColor("yellow") if x else QColor("white")
)
)
def set_time(self):
if self.get_radio_button("radioButton_time"):
self.find(QLabel, "label_date").setEnabled(False)
self.find(QDateTimeEdit, "dateTimeEdit_date").setEnabled(False)
def set_date(self):
if self.get_radio_button("radioButton_date"):
self.find(QLabel, "label_date").setEnabled(True)
self.find(QDateTimeEdit, "dateTimeEdit_date").setEnabled(True)
def accept(self):
name = self.get_line_edit_text("lineEdit_name")
description = self.get_text_edit_text("textEdit_description")
if self._study is None:
study = Study.new(name, description)
study.river.init_default()
if self.get_radio_button("radioButton_date"):
date = self.get_datetime_edit("dateTimeEdit_date")
study.use_date(date)
self.parent.set_model(study)
else:
self._study.name = name
self._study.description = description
if self.get_radio_button("radioButton_date"):
date = self.get_datetime_edit("dateTimeEdit_date")
self._study.use_date(date)
else:
self._study.use_time()
self.done(True)