mirror of https://gitlab.com/pamhyr/pamhyr2
configure: Add message box and minor change.
parent
4ff4e877ff
commit
5e0e1e5c5e
|
|
@ -11,7 +11,6 @@ from model.Study import Study
|
|||
|
||||
def main():
|
||||
conf = Config.load()
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
application = ApplicationWindow(conf=conf)
|
||||
application.show()
|
||||
|
|
|
|||
|
|
@ -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_()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue