diff --git a/src/pamhyr.py b/src/pamhyr.py index 7c755d882b07caa5599a5ddd88a36961f39d687a..1d7cf0e55af344682100de34f52631fabf326dca 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 eaa2863817c8c8a0f6a73a81d37f6e4fcb855ec8..f6598b667533afe606c63fe6f5d3c6481cc5b8c9 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 0000000000000000000000000000000000000000..8414691bf42c72a16b552ecd6e5cad05ca82607b --- /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 0000000000000000000000000000000000000000..623834f678fe9016fb674ab20b444331e9e109f9 --- /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 684d3c42707dc1b8c0a4cd5e0a71466b5d0232f9..1940cbbb435dc3f1b4734df542daef2f33909a1b 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 0000000000000000000000000000000000000000..8447a904346b1bd58949bbd50a57cb48bbc59008 --- /dev/null +++ b/src/view/ui/about.ui @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>362</width> + <height>98</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <widget class="QWidget" name=""> + <property name="geometry"> + <rect> + <x>10</x> + <y>10</y> + <width>341</width> + <height>81</height> + </rect> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap>ressources/logoCemagref.gif</pixmap> + </property> + <property name="scaledContents"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label_2"> + <property name="font"> + <font> + <pointsize>16</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="text"> + <string>PamHyr</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Version en developpement:</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </widget> + <resources/> + <connections/> +</ui> diff --git a/src/view/ui/dummy.ui b/src/view/ui/dummy.ui new file mode 100644 index 0000000000000000000000000000000000000000..99353cd2babd65e7341a5b5019d409f0e31abe74 --- /dev/null +++ b/src/view/ui/dummy.ui @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QWidget" name="Form"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + </widget> + <resources/> + <connections/> +</ui>