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():
|
def main():
|
||||||
conf = Config.load()
|
conf = Config.load()
|
||||||
|
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
application = ApplicationWindow(conf=conf)
|
application = ApplicationWindow(conf=conf)
|
||||||
application.show()
|
application.show()
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ from PyQt5.QtWidgets import (
|
||||||
QPushButton, QLineEdit, QCheckBox,
|
QPushButton, QLineEdit, QCheckBox,
|
||||||
QTimeEdit, QSpinBox, QTextEdit,
|
QTimeEdit, QSpinBox, QTextEdit,
|
||||||
QRadioButton, QComboBox, QFileDialog,
|
QRadioButton, QComboBox, QFileDialog,
|
||||||
|
QMessageBox,
|
||||||
)
|
)
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
QTime,
|
QTime,
|
||||||
|
|
@ -210,6 +211,15 @@ class ASubWindow(QDialog):
|
||||||
|
|
||||||
# Custom dialog
|
# Custom dialog
|
||||||
def file_dialog(self, select_file=True, callback=lambda x: None):
|
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)
|
dialog = QFileDialog(self)
|
||||||
|
|
||||||
if select_file:
|
if select_file:
|
||||||
|
|
@ -222,3 +232,18 @@ class ASubWindow(QDialog):
|
||||||
if dialog.exec_():
|
if dialog.exec_():
|
||||||
file_names = dialog.selectedFiles()
|
file_names = dialog.selectedFiles()
|
||||||
callback(file_names)
|
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 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from solver.Solvers import solver_type_list
|
||||||
|
|
||||||
from view.ASubWindow import ASubWindow
|
from view.ASubWindow import ASubWindow
|
||||||
from solver.GenericSolver import GenericSolver
|
from solver.GenericSolver import GenericSolver
|
||||||
|
|
||||||
|
|
@ -15,9 +17,8 @@ class ConfigureAddSolverWindow(ASubWindow):
|
||||||
self.ui.setWindowTitle(title)
|
self.ui.setWindowTitle(title)
|
||||||
|
|
||||||
# Combo box item
|
# Combo box item
|
||||||
self.combobox_add_item("comboBox_solver", "Generic")
|
for solver in solver_type_list:
|
||||||
self.combobox_add_item("comboBox_solver", "Mage")
|
self.combobox_add_item("comboBox_solver", solver)
|
||||||
self.combobox_add_item("comboBox_solver", "Rubarbe")
|
|
||||||
|
|
||||||
# Data to return
|
# Data to return
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
@ -58,6 +59,12 @@ class ConfigureAddSolverWindow(ASubWindow):
|
||||||
self.find(QPushButton, button).clicked.connect(buttons[button])
|
self.find(QPushButton, button).clicked.connect(buttons[button])
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
|
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 = GenericSolver(self.get_line_edit_text("lineEdit_name"))
|
||||||
self.data.set_description(self.get_line_edit_text("lineEdit_description"))
|
self.data.set_description(self.get_line_edit_text("lineEdit_description"))
|
||||||
self.data.set_input(
|
self.data.set_input(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue