diff --git a/src/pamhyr.py b/src/pamhyr.py index 7c755d88..1d7cf0e5 100755 --- a/src/pamhyr.py +++ b/src/pamhyr.py @@ -7,14 +7,9 @@ from PyQt5.QtWidgets import QApplication from view.MainWindow import ApplicationWindow from model.Study import Study -class Application(ApplicationWindow): - def __init__(self): - super(Application, self).__init__() - self.study = Study.new("dummy", "dummy.pkl") - def main(): app = QApplication(sys.argv) - application = Application() + application = ApplicationWindow() application.show() sys.exit(app.exec_()) diff --git a/src/view/ASubWindow.py b/src/view/ASubWindow.py index eaa28638..f6598b66 100644 --- a/src/view/ASubWindow.py +++ b/src/view/ASubWindow.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +import os + from PyQt5.QtWidgets import ( QMainWindow, QApplication, QDesktopWidget, QMdiArea, QMdiSubWindow, QDialog, @@ -14,6 +16,10 @@ from PyQt5.uic import loadUi # loadUi(f"ui/{ui}.ui", self) class ASubWindow(QDialog): - def __init__(self, ui="error"): - super(ASubWindow, self).__init__() - loadUi(f"ui/{ui}.ui", self) + def __init__(self, name="", ui="dummy", parent=None): + super(ASubWindow, self).__init__(parent=parent) + self.ui = loadUi( + os.path.join(os.path.dirname(__file__), "ui", f"{ui}.ui"), + self + ) + self.name = name diff --git a/src/view/AboutWindow.py b/src/view/AboutWindow.py new file mode 100644 index 00000000..8414691b --- /dev/null +++ b/src/view/AboutWindow.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +from view.ASubWindow import ASubWindow + +class AboutWindow(ASubWindow): + def __init__(self, title="About", parent=None): + super(AboutWindow, self).__init__(ui="about", parent=parent) + self.ui.setWindowTitle(title) diff --git a/src/view/DummyWindow.py b/src/view/DummyWindow.py new file mode 100644 index 00000000..623834f6 --- /dev/null +++ b/src/view/DummyWindow.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- + +from view.ASubWindow import ASubWindow + +class DummyWindow(ASubWindow): + def __init__(self, title="Dummy", parent=None): + super(DummyWindow, self).__init__(ui="dummy", parent=parent) + self.ui.setWindowTitle(title) diff --git a/src/view/MainWindow.py b/src/view/MainWindow.py index 684d3c42..1940cbbb 100644 --- a/src/view/MainWindow.py +++ b/src/view/MainWindow.py @@ -4,9 +4,11 @@ import os from PyQt5 import QtGui from PyQt5.QtWidgets import ( - QMainWindow, QApplication, + QMainWindow, QApplication, QAction, ) from PyQt5.uic import loadUi +from view.DummyWindow import DummyWindow +from view.AboutWindow import AboutWindow class ApplicationWindow(QMainWindow): def __init__(self): @@ -16,3 +18,50 @@ class ApplicationWindow(QMainWindow): self ) self.showMaximized() + self.basic_callback() + + def open_dummy(self, title="Dummy"): + """ + Open a dummy dialog window. + """ + self.dummy = DummyWindow( + title=title if type(title) is str else "Dummy", + parent=self + ) + self.dummy.show() + + def open_about(self): + self.about = AboutWindow(parent=self) + self.about.show() + + def basic_callback(self): + """ + Connect action to callback function. + """ + actions = { + # Menu action + "actionA_propos": self.open_about, + # ToolBar action + "actionOuvrir_une_tude": self.open_dummy, + "actionenregistrer_etude_en_cours": self.open_dummy, + "actionfermer_etude_en_cours": self.open_dummy, + "actionquitter_application": self.open_dummy, + "actionlancer_solveur": self.open_dummy, + "actioninterrompt_simulation_en_cours": self.open_dummy, + "actionafficher_listings_simulation": self.open_dummy, + "actionlancer_solveur": self.open_dummy, + "actionReseau": lambda : self.open_dummy("Networks"), + "actionGeometrie": lambda : self.open_dummy("Geomerty"), + "actionMaillage": lambda : self.open_dummy("Maillage"), + "actionlancer_mailleur_externe": lambda : self.open_dummy("Lancement mailleur externe"), + "actionCond_Limites": lambda : self.open_dummy("Condition Limites"), + "actionApp_Lat_raux": lambda : self.open_dummy("Apport Lateraux"), + "actionDeversements": lambda : self.open_dummy("Deversement"), + "actionTroncons": lambda : self.open_dummy("Tronçons"), + "actionFrottements": lambda : self.open_dummy("Frottements"), + "actionOuvrages": lambda : self.open_dummy("Ouvrages"), + } + + for action in actions: + self.ui.findChild(QAction, action)\ + .triggered.connect(actions[action]) diff --git a/src/view/ui/about.ui b/src/view/ui/about.ui new file mode 100644 index 00000000..8447a904 --- /dev/null +++ b/src/view/ui/about.ui @@ -0,0 +1,69 @@ + + + Form + + + + 0 + 0 + 362 + 98 + + + + Form + + + + + 10 + 10 + 341 + 81 + + + + + + + + + + ressources/logoCemagref.gif + + + true + + + + + + + + + + 16 + 75 + true + + + + PamHyr + + + + + + + Version en developpement: + + + + + + + + + + + diff --git a/src/view/ui/dummy.ui b/src/view/ui/dummy.ui new file mode 100644 index 00000000..99353cd2 --- /dev/null +++ b/src/view/ui/dummy.ui @@ -0,0 +1,19 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + +