def auth(self): if PasswordExist(str(self.identifiantEdit.text()), str(self.motDePasseEdit.text())): self.close() QMessageBox.information( self, self.trUtf8("Authentification réussie"), self.trUtf8("Bonjour <strong>" + self.identifiantEdit.text() + "</strong> !"), ) self.ex = GuiMain(str(self.identifiantEdit.text())) self.ex.show() else: QMessageBox.critical( self, self.trUtf8("Erreur authentification"), self.trUtf8("L' identifiant et/ou le mot de passe sont incorrect !"), )
# coding=utf-8 from GuiMain import * if __name__ == '__main__': # 实例化GuiMain gui = GuiMain() #gui.iconbitmap('cat64_64.ico') # 主消息循环: gui.mainloop()
class GuiConnexion(QWidget): def __init__(self): super(GuiConnexion, self).__init__() self.initUI() def initUI(self): self.resize(350, 150) self.center() self.accueil = QLabel("Fenetre de connexion") self.identifiant = QLabel("Identifiant :") self.motDePasse = QLabel("Mot de passe :") self.login = QPushButton("Se connecter", self) self.connect(self.login, SIGNAL("clicked()"), self.auth) self.login.resize(150, 30) self.identifiantEdit = QLineEdit() self.motDePasseEdit = QLineEdit() self.motDePasseEdit.setEchoMode(QLineEdit.Password) self.grid = QGridLayout() self.grid.setSpacing(15) self.grid.addWidget(self.accueil, 1, 0) self.grid.addWidget(self.identifiant, 2, 0) self.grid.addWidget(self.identifiantEdit, 2, 1) self.grid.addWidget(self.motDePasse, 3, 0) self.grid.addWidget(self.motDePasseEdit, 3, 1) self.grid.addWidget(self.login, 4, 1) self.setLayout(self.grid) self.setWindowTitle("Gestion de Ludotech") self.show() def center(self): qr = self.frameGeometry() cp = QDesktopWidget().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft()) def auth(self): if PasswordExist(str(self.identifiantEdit.text()), str(self.motDePasseEdit.text())): self.close() QMessageBox.information( self, self.trUtf8("Authentification réussie"), self.trUtf8("Bonjour <strong>" + self.identifiantEdit.text() + "</strong> !"), ) self.ex = GuiMain(str(self.identifiantEdit.text())) self.ex.show() else: QMessageBox.critical( self, self.trUtf8("Erreur authentification"), self.trUtf8("L' identifiant et/ou le mot de passe sont incorrect !"), )