Commit a56da303 authored by Maël RENAULT's avatar Maël RENAULT
Browse files

Update IHM_Sudoku.py

parent acb9d337
from PyQt5.QtCore import Qt
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import numpy as np
from PyQt5.QtGui import *
......@@ -32,6 +32,7 @@ class Grille_sudoku(QWidget):
self.digitButtonsWhite = []
self.digitButtonsGrey = []
self.grille_utilise = None
self.vies = 3
for i in range(0,9):
Grille_sudoku.k = (i//3 == 0 or i//3 == 2)
......@@ -130,11 +131,23 @@ class Grille_sudoku(QWidget):
else:
clickedButton.setText(item)
clickedButton.setStyleSheet("background-color : red")
#self.vies = self.vies - 1
#def warningMessage(self):
# msgBox = QMessageBox(QMessageBox.Warning, "QMessageBox.warning()",
# Dialog.MESSAGE, QMessageBox.NoButton, self)
# msgBox.addButton("Save &Again", QMessageBox.AcceptRole)
# msgBox.addButton("&Continue", QMessageBox.RejectRole)
# if msgBox.exec_() == QMessageBox.AcceptRole:
# self.warningLabel.setText("Save Again")
# else:
# self.warningLabel.setText("Continue")
def nouvelle_grille(self):
grl = Grille()
items = ('Facile','Moyen','Difficile')
self.vies = 3
items = ('Facile','Moyen','Difficile','Diabolique')
item, ok = QInputDialog.getItem(self, "Choix de la Difficulté",
"Difficulté", items, 0, False)
if ok and item == 'Facile':
......@@ -149,6 +162,10 @@ class Grille_sudoku(QWidget):
grl.génération(5000)
grille = grl.supprimer_cases(35)
self.charger_une_grille(grille)
elif ok and item == 'Diabolique':
grl.génération(5000)
grille = grl.supprimer_cases(50)
self.charger_une_grille(grille)
def open(self):
options = QFileDialog.Options()
......@@ -166,19 +183,22 @@ class Grille_sudoku(QWidget):
self.charger_une_grille(grille)
def save(self):
user = "louis"
grille = copy.deepcopy(self.grille_utilise)
nom_fichier = "sauvegarde_" + str(user) + "_" + strftime("%d_%m_%Y_%Hh%Mm%Ss") + ".txt"
fichier = open(nom_fichier, "a")
fichier.write(str(user) + " " + strftime("%d_%m_%Y_%H:%M:%S") + "\n")
for i in range(grille.shape[0]):
for j in range(grille.shape[1]):
if j == (grille.shape[1] - 1):
fichier.write(str(grille[i, j]) + "\n")
else:
fichier.write(str(grille[i, j]))
fichier.close()
text, ok = QInputDialog.getText(self, "Nom",
"Nom du Joueur :", QLineEdit.Normal, QDir.home().dirName())
if ok and text != '':
user = text
grille = copy.deepcopy(self.grille_utilise)
nom_fichier = "sauvegarde_" + str(user) + "_" + strftime("%d_%m_%Y_%Hh%Mm%Ss") + ".txt"
fichier = open(nom_fichier, "a")
fichier.write(str(user) + " " + strftime("%d_%m_%Y_%H:%M:%S") + "\n")
for i in range(grille.shape[0]):
for j in range(grille.shape[1]):
if j == (grille.shape[1] - 1):
fichier.write(str(grille[i, j]) + "\n")
else:
fichier.write(str(grille[i, j]))
fichier.close()
def solution(self):
ordi = Ordinateur()
......@@ -253,9 +273,8 @@ class Correction(Grille_sudoku):
self.setLayout(mainLayout)
mainLayout2.addWidget(testWidget)
self.setWindowTitle("Solution")
self.setWindowIcon(QIcon('icone_solution.jpg'))
self.setWindowTitle("Solution")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment