1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| #!/usr/bin/env python3
# coding: utf-8
# On importe les bibliothèques nécessaires
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5 import QtCore
import sys
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
# set window properties
self.setWindowTitle("Jeu de Piste Manon")
print("debut init:" +str(self.size()))
self.central_widget = QStackedWidget()
self.setCentralWidget(self.central_widget)
self.principal = Principale(self)
self.logo = QLabel()
self.photo = QLabel()
self.qr = QLabel()
self.final = QLabel()
self.central_widget.addWidget(self.principal)
self.central_widget.addWidget(self.logo)
self.central_widget.addWidget(self.photo)
self.central_widget.addWidget(self.qr)
self.central_widget.addWidget(self.final)
self.central_widget.setCurrentWidget(self.principal)
self.resize(self.size())
c=app.desktop().availableGeometry().center()
print("center screen: ", c)
self.move(c.x() - self.width() // 2, c.y() - self.height() // 2)
print("fin init:" +str(self.size()))
class Principale(QWidget):
def __init__(self, parent=None):
super(Principale, self).__init__(parent)
#Initialise l'enigme a 1
self.current_enigma= 1
self.etape14 = 0
print("debut principale:" +str(self.size()))
# create label and set font
self.label_réponse = QLabel("Entre ta réponse :")
self.label_intitulé = QLabel("")
self.label_resulat = QLabel("")
self.label_created_by = QLabel("Created by Maxime")
# create label for created by text and set font and alignment
self.label_created_by.setFont(QFont("Times New Roman", 9))
self.label_réponse.setFont(QFont("Arial", 12))
self.label_intitulé.setFont(QFont("Times New Roman", 13,italic=True))
self.label_resulat.setFont(QFont("Times New Roman", 12))
# create text input field and set font
self.text_input = QLineEdit()
self.text_input.setFont(QFont("Arial", 20))
self.text_input.setMaximumWidth(200)
# create next button and set font and size
self.next_button = QPushButton("Suivant")
self.next_button.setFont(QFont("Arial", 12))
self.next_button.setStyleSheet("background-color: green; color: white;")
self.next_button.setMaximumWidth(100)
# create previous button and set font and size
self.prev_button = QPushButton("Précédent")
self.prev_button.setFont(QFont("Arial", 12))
self.prev_button.setStyleSheet("background-color: red; color: white;")
self.prev_button.setMaximumWidth(100)
# set layout and add components
self.vbox = QVBoxLayout()
self.vbox.addWidget(self.label_intitulé, alignment=QtCore.Qt.AlignCenter)
self.vbox.addWidget(self.label_réponse, alignment=QtCore.Qt.AlignCenter)
self.vbox.addWidget(self.text_input, alignment=QtCore.Qt.AlignCenter)
self.vbox.addWidget(self.label_resulat, alignment=QtCore.Qt.AlignCenter)
hbox = QHBoxLayout()
hbox.addWidget(self.prev_button, alignment=QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom)
hbox.addWidget(self.next_button, alignment=QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom)
self.vbox.addLayout(hbox)
self.vbox.addWidget(self.label_created_by, alignment=QtCore.Qt.AlignBottom | QtCore.Qt.AlignRight)
self.setLayout(self.vbox)
print("fin principale:" +str(self.size()))
#initialisation du texte enigme + bouton
# L'application (élément de base)
app=QApplication(sys.argv)
# Le QMainWindow
main=MainWindow()
main.show()
# Application
sys.exit(app.exec_()) |
Partager