Commit d4db0b65 authored by Aurelien Dufour's avatar Aurelien Dufour
Browse files

modification du menuBar, relier le bouton quitter à un pop up permettant de quitter l'application

parent 588858ea
Loading
Loading
Loading
Loading
+0 −7
Original line number Diff line number Diff line
@@ -5,19 +5,12 @@ from PyQt5.QtWidgets import QApplication

from controller.menuController import MenuController
from model.game import Game
from model.node import BinaryNode, Leaf
from model.tree import Tree
from view.menu import Menu


def launchApplication():
    qapp = QApplication(sys.argv)
    app = Menu()
    app.paramWindow(1200, 600, "Initiation au parcours d'arbre")
    app.addSubMenus("&Jeu", {""""&Nouvelle partie": app.launchGame,""" "&Niveaux": None, "&Quitter": None})
    app.addSubMenus("&Aide", {"&Aide": None})
    app.addSubMenus("&A propos", {"&A propos": None})
    app.displayGames()
    controller = MenuController(app, Game())
    app.window.show()
    qapp.exec_()
+0 −1
Original line number Diff line number Diff line
import math
from random import randint

from model.game import Game
+35 −9
Original line number Diff line number Diff line
@@ -5,9 +5,8 @@ from PyQt5.QtWidgets import *
from controller.dyckWordToBinaryTree import DyckWordToBinaryTree
from model.game import Game
from model.GameEnum import nbGames, GameEnum
from view.binaryTreeToDyckWordGui import BinaryTreeToDyckWordGui
from view.dyckWordToBinaryTreeGui import DyckWordToBinaryTreeGui
from view.gameButton import GameButton
from PyQt5.QtCore import Qt


class MyWindow(QMainWindow):
@@ -30,6 +29,9 @@ class Menu:
        self.gameButtons = []
        self.centralLayout = QHBoxLayout(self.window.centralWidget())
        self.game = Game()
        self.paramWindow(1200, 600, "Initiation au parcours d'arbre")
        self.addSubMenus()
        self.displayGames()

    def resizeEvent(self, e):
        pass
@@ -40,16 +42,40 @@ class Menu:
        self.window.setWindowTitle(title)

    # function to create submenus in the menubar which are linked to actions
    def addSubMenus(self, subMenuName, actions):
    def addSubMenus(self):

        # creation of submenus
        subMenu = self.window.menuBar().addMenu(subMenuName)
        menu = self.window.menuBar().addMenu("&Menu")
        help = self.window.menuBar().addMenu("&Aide")
        info = self.window.menuBar().addMenu("&A propos")

        # we add actions to the submenu
        for actionName, fence in actions.items():
            action = QAction(actionName, self.window)
            if fence is not None:
                action.triggered.connect(fence)
            subMenu.addAction(action)
        self.menuAction = QAction("&Menu", self.window)
        self.leaveAction = QAction("&Quitter", self.window)
        self.leaveAction.triggered.connect(self.close)
        self.helpAction = QAction("&Aide", self.window)
        self.infoAction = QAction("&A propos", self.window)

        menu.addAction(self.menuAction)
        menu.addAction(self.leaveAction)
        help.addAction(self.helpAction)
        info.addAction(self.infoAction)

    def close(self):
        msgBox = QMessageBox()
        msgBox.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint)
        noButton = QPushButton("Non")
        yesButton = QPushButton("Oui")
        yesButton.clicked.connect(self.window.close)
        msgBox.setWindowTitle("A bientôt!")
        msgBox.setText("Es-tu certains de vouloir quitter l'application?")
        msgBox.addButton(yesButton, QMessageBox.NoRole)
        msgBox.addButton(noButton, QMessageBox.YesRole)
        msgBox.setDefaultButton(noButton)
        msgBox.exec()

    def test(self):
        print("test")

    # function to put the central widget in the menu
    def displayGames(self):