MainWindow.py 2.44 KB
Newer Older
# -*- coding: utf-8 -*-

import os

from PyQt5 import QtGui
from PyQt5.QtWidgets import (
    QMainWindow, QApplication, QAction,
)
from PyQt5.uic import loadUi
from view.DummyWindow import DummyWindow
from view.AboutWindow import AboutWindow

class ApplicationWindow(QMainWindow):
    def __init__(self):
        super(ApplicationWindow, self).__init__()
        self.ui = loadUi(
            os.path.join(os.path.dirname(__file__), "ui", "MainWindow.ui"),
            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])