diff --git a/src/pamhyr.py b/src/pamhyr.py index ec9f74f0bb55ec43595b355a7822b48bb7261b9b..53a99404b5baec6a7c5bc8368ca3a1a73ccca231 100755 --- a/src/pamhyr.py +++ b/src/pamhyr.py @@ -11,7 +11,6 @@ from model.Study import Study def main(): conf = Config.load() - app = QApplication(sys.argv) application = ApplicationWindow(conf=conf) application.show() diff --git a/src/view/ASubWindow.py b/src/view/ASubWindow.py index 968f54ab7265f07fd977228c7fad0d6373a492dd..3764193e2ffc9e4d76741a5866abc768b29dbab4 100644 --- a/src/view/ASubWindow.py +++ b/src/view/ASubWindow.py @@ -8,6 +8,7 @@ from PyQt5.QtWidgets import ( QPushButton, QLineEdit, QCheckBox, QTimeEdit, QSpinBox, QTextEdit, QRadioButton, QComboBox, QFileDialog, + QMessageBox, ) from PyQt5.QtCore import ( QTime, @@ -210,6 +211,15 @@ class ASubWindow(QDialog): # Custom dialog def file_dialog(self, select_file=True, callback=lambda x: None): + """Open a new file dialog and send result to callback function + + Args: + select_file: Select a file if True, else select a dir + callback: The callback function + + Returns: + Nothing + """ dialog = QFileDialog(self) if select_file: @@ -222,3 +232,18 @@ class ASubWindow(QDialog): if dialog.exec_(): file_names = dialog.selectedFiles() callback(file_names) + + def message_box(self, value, + text: str, + informative_text: str, + window_title: str = "Warning"): + msg = QMessageBox() + msg.setIcon(QMessageBox.Warning) + msg.setText(f"{value} : {text}") + msg.setInformativeText(f"{informative_text}") + msg.setWindowTitle(f"{window_title}") + # msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + _width = len(f"{text} : {value}") + msg.setStyleSheet("QLabel{min-width:200 px; font-size: 13px;} QPushButton{width:10px; font-size: 12px};" + "background-color: Ligthgray; color : gray; font-size: 8pt; color: #888a80;") + msg.exec_() diff --git a/src/view/ConfigureAddSolverWindow.py b/src/view/ConfigureAddSolverWindow.py index 0246477e9b8e67a0d7ee7379e6d3085fd2d044f9..47099b1d7d9565153a3de9e41680821639d4f262 100644 --- a/src/view/ConfigureAddSolverWindow.py +++ b/src/view/ConfigureAddSolverWindow.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +from solver.Solvers import solver_type_list + from view.ASubWindow import ASubWindow from solver.GenericSolver import GenericSolver @@ -15,9 +17,8 @@ class ConfigureAddSolverWindow(ASubWindow): self.ui.setWindowTitle(title) # Combo box item - self.combobox_add_item("comboBox_solver", "Generic") - self.combobox_add_item("comboBox_solver", "Mage") - self.combobox_add_item("comboBox_solver", "Rubarbe") + for solver in solver_type_list: + self.combobox_add_item("comboBox_solver", solver) # Data to return self.data = data @@ -58,19 +59,25 @@ class ConfigureAddSolverWindow(ASubWindow): self.find(QPushButton, button).clicked.connect(buttons[button]) def accept(self): - self.data = GenericSolver(self.get_line_edit_text("lineEdit_name")) - self.data.set_description(self.get_line_edit_text("lineEdit_description")) - self.data.set_input( - self.get_line_edit_text("lineEdit_input"), - self.get_line_edit_text("lineEdit_input_cmd") - ) - self.data.set_solver( - self.get_line_edit_text("lineEdit_solver"), - self.get_line_edit_text("lineEdit_solver_cmd") - ) - self.data.set_output( - self.get_line_edit_text("lineEdit_output"), - self.get_line_edit_text("lineEdit_output_cmd") - ) + if self.get_line_edit_text("lineEdit_name") == "": + self.message_box( + "Add solver", "A solver need a name", + "Please give a name to your solver" + ) + else: + self.data = GenericSolver(self.get_line_edit_text("lineEdit_name")) + self.data.set_description(self.get_line_edit_text("lineEdit_description")) + self.data.set_input( + self.get_line_edit_text("lineEdit_input"), + self.get_line_edit_text("lineEdit_input_cmd") + ) + self.data.set_solver( + self.get_line_edit_text("lineEdit_solver"), + self.get_line_edit_text("lineEdit_solver_cmd") + ) + self.data.set_output( + self.get_line_edit_text("lineEdit_output"), + self.get_line_edit_text("lineEdit_output_cmd") + ) - self.done(True) + self.done(True)