From 0ae697096c63987b452e4fb5962f186b5368326d Mon Sep 17 00:00:00 2001 From: Djalim Simaila Date: Tue, 2 May 2023 10:09:54 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor(MainWindow.py):=20add?= =?UTF-8?q?=20graph=5Ftype=5Fchanged=20method=20to=20handle=20changes=20in?= =?UTF-8?q?=20graph=20type=20selection=20=E2=9C=A8=20feat(MainWindow.ui):?= =?UTF-8?q?=20add=20a=20label=20and=20a=20spinbox=20to=20display=20the=20n?= =?UTF-8?q?umber=20of=20graphs=20selected=20The=20graph=5Ftype=5Fchanged?= =?UTF-8?q?=20method=20is=20added=20to=20handle=20changes=20in=20the=20gra?= =?UTF-8?q?ph=20type=20selection.=20It=20updates=20the=20number=20of=20gra?= =?UTF-8?q?phs=20selected=20and=20displays=20it=20in=20the=20newly=20added?= =?UTF-8?q?=20spinbox.=20The=20label=20is=20also=20added=20to=20display=20?= =?UTF-8?q?the=20text=20"Nombre=20de=20graphes=20:".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/gui/pyqt/main_window/MainWindow.py | 17 ++++++++- utils/gui/pyqt/main_window/MainWindow.ui | 42 ++++++++++++++++----- utils/gui/pyqt/main_window/UI_MainWindow.py | 15 +++++++- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/utils/gui/pyqt/main_window/MainWindow.py b/utils/gui/pyqt/main_window/MainWindow.py index d5795ee..19f862f 100644 --- a/utils/gui/pyqt/main_window/MainWindow.py +++ b/utils/gui/pyqt/main_window/MainWindow.py @@ -69,6 +69,7 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): for combo_box in self.combo_boxes: combo_box.addItems(self.graphType) + combo_box.currentIndexChanged.connect(self.graph_type_changed) self.slots = [ [self.slot0,"Aucun"], @@ -87,6 +88,9 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): for slot_nb,slot in enumerate(self.slots): slot[1] = SettingManager.get_instance().get_last_graph(slot_nb) self.combo_boxes[slot_nb].setCurrentText(slot[1]) + + self.graph_nb =0 + self.graph_type_changed() self.settings_window = Settings() @@ -341,7 +345,6 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): for i in reversed(range(slot.count())): slot.itemAt(i).widget().setParent(None) - ############################################################################### # # # # @@ -377,4 +380,14 @@ class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): """ Show the settings window """ - self.settings_window.show() \ No newline at end of file + self.settings_window.show() + + def graph_type_changed(self): + """ + Update the number of graphs + """ + self.graph_nb = 0 + for combo_box in self.combo_boxes: + if combo_box.currentIndex() != 0: + self.graph_nb += 1 + self.graph_nb_spinbox.setValue(self.graph_nb) \ No newline at end of file diff --git a/utils/gui/pyqt/main_window/MainWindow.ui b/utils/gui/pyqt/main_window/MainWindow.ui index a3c9ec4..7ed1eeb 100644 --- a/utils/gui/pyqt/main_window/MainWindow.ui +++ b/utils/gui/pyqt/main_window/MainWindow.ui @@ -117,15 +117,39 @@ - - - - afficher les graphes - - - true - - + + + + + + afficher les graphes + + + true + + + + + + + Nombre de graphes : + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + QAbstractSpinBox::NoButtons + + + + diff --git a/utils/gui/pyqt/main_window/UI_MainWindow.py b/utils/gui/pyqt/main_window/UI_MainWindow.py index 2f0b2e6..c719d0f 100644 --- a/utils/gui/pyqt/main_window/UI_MainWindow.py +++ b/utils/gui/pyqt/main_window/UI_MainWindow.py @@ -75,10 +75,22 @@ class Ui_MainWindow(object): self.analyse_progress_bar.setProperty("value", 0) self.analyse_progress_bar.setObjectName("analyse_progress_bar") self.MainSettingsLayout.addWidget(self.analyse_progress_bar) + self.graphs_params_layout = QtWidgets.QHBoxLayout() + self.graphs_params_layout.setObjectName("graphs_params_layout") self.show_graph_checkbox = QtWidgets.QCheckBox(self.MainSettings) self.show_graph_checkbox.setChecked(True) self.show_graph_checkbox.setObjectName("show_graph_checkbox") - self.MainSettingsLayout.addWidget(self.show_graph_checkbox, 0, QtCore.Qt.AlignHCenter) + self.graphs_params_layout.addWidget(self.show_graph_checkbox) + self.label = QtWidgets.QLabel(self.MainSettings) + self.label.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) + self.label.setObjectName("label") + self.graphs_params_layout.addWidget(self.label) + self.graph_nb_spinbox = QtWidgets.QSpinBox(self.MainSettings) + self.graph_nb_spinbox.setReadOnly(True) + self.graph_nb_spinbox.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons) + self.graph_nb_spinbox.setObjectName("graph_nb_spinbox") + self.graphs_params_layout.addWidget(self.graph_nb_spinbox) + self.MainSettingsLayout.addLayout(self.graphs_params_layout) self.start_analyse_button = QtWidgets.QPushButton(self.MainSettings) self.start_analyse_button.setObjectName("start_analyse_button") self.MainSettingsLayout.addWidget(self.start_analyse_button) @@ -307,6 +319,7 @@ class Ui_MainWindow(object): self.output_file_prefix_label.setText(_translate("MainWindow", "Préfix du fichier de sortie")) self.discretisation_label.setText(_translate("MainWindow", "Discretisation (en mm)")) self.show_graph_checkbox.setText(_translate("MainWindow", "afficher les graphes")) + self.label.setText(_translate("MainWindow", "Nombre de graphes :")) self.start_analyse_button.setText(_translate("MainWindow", "Analyser le fichier")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "1")) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "2"))