daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from PyQt5.QtWidgets import QDialog, QApplication, QMainWindow, QMessageBox
  2. from PyQt5 import QtCore, QtGui, QtWidgets
  3. from view.FormPrincipal import Ui_FormPrincipal
  4. from controller.UsuarioCTR import UsuarioCTR
  5.  
  6. class Ui_FormLogin(object):
  7.  
  8.     def click_btn_login(self):
  9.         usuario = self.editUsuario.text()
  10.         senha = self.editSenha.text()
  11.         aux = UsuarioCTR.autentica_usuario(usuario, senha)
  12.         if (aux == True):
  13.             self.formprincipal = QMainWindow()
  14.             self.ui = Ui_FormPrincipal()
  15.             self.ui.setupUi(self.formprincipal)
  16.             self.formprincipal.show()
  17.  
  18.         elif(aux == False):
  19.             msg = QMessageBox(None)
  20.             msg.setWindowTitle("Erro")
  21.             msg.setWindowIcon(QtGui.QIcon("key.png"))
  22.             msg.setIcon(QMessageBox.Critical)
  23.             msg.setText("Senha incorreta.")
  24.             msg.exec_()
  25.             self.editUsuario.clear()
  26.             self.editSenha.clear()
  27.  
  28.  
  29.     def setupUi(self, FormLogin):
  30.         FormLogin.setObjectName("FormLogin")
  31.         FormLogin.resize(432, 148)
  32.         icon = QtGui.QIcon()
  33.         icon.addPixmap(QtGui.QPixmap("login.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  34.         FormLogin.setWindowIcon(icon)
  35.         FormLogin.setStyleSheet("background-color: rgb(13, 42, 172);")
  36.         self.pushButton = QtWidgets.QPushButton(FormLogin)
  37.         self.pushButton.setGeometry(QtCore.QRect(350, 60, 75, 23))
  38.         self.pushButton.setStyleSheet("background-color: rgb(255, 255, 255);")
  39.         self.pushButton.setObjectName("pushButton")
  40.         self.pushButton_2 = QtWidgets.QPushButton(FormLogin)
  41.         self.pushButton_2.setGeometry(QtCore.QRect(350, 90, 75, 23))
  42.         self.pushButton_2.setStyleSheet("background-color: rgb(255, 255, 255);")
  43.         self.pushButton_2.setObjectName("pushButton_2")
  44.         self.label_3 = QtWidgets.QLabel(FormLogin)
  45.         self.label_3.setGeometry(QtCore.QRect(10, 30, 91, 101))
  46.         self.label_3.setStyleSheet("image: url(key.png);")
  47.         self.label_3.setText("")
  48.         self.label_3.setObjectName("label_3")
  49.         self.widget = QtWidgets.QWidget(FormLogin)
  50.         self.widget.setGeometry(QtCore.QRect(120, 20, 191, 96))
  51.         self.widget.setObjectName("widget")
  52.         self.verticalLayout = QtWidgets.QVBoxLayout(self.widget)
  53.         self.verticalLayout.setContentsMargins(0, 0, 0, 0)
  54.         self.verticalLayout.setObjectName("verticalLayout")
  55.         self.label = QtWidgets.QLabel(self.widget)
  56.         font = QtGui.QFont()
  57.         font.setPointSize(10)
  58.         self.label.setFont(font)
  59.         self.label.setStyleSheet("color: rgb(255, 255, 255);")
  60.         self.label.setObjectName("label")
  61.         self.verticalLayout.addWidget(self.label)
  62.         self.editUsuario = QtWidgets.QLineEdit(self.widget)
  63.         font = QtGui.QFont()
  64.         font.setPointSize(10)
  65.         self.editUsuario.setFont(font)
  66.         self.editUsuario.setStyleSheet("background-color: rgb(255, 255, 255);")
  67.         self.editUsuario.setObjectName("editUsuario")
  68.         self.verticalLayout.addWidget(self.editUsuario)
  69.         self.label_2 = QtWidgets.QLabel(self.widget)
  70.         font = QtGui.QFont()
  71.         font.setPointSize(10)
  72.         self.label_2.setFont(font)
  73.         self.label_2.setStyleSheet("color: rgb(255, 255, 255);")
  74.         self.label_2.setObjectName("label_2")
  75.         self.verticalLayout.addWidget(self.label_2)
  76.         self.editSenha = QtWidgets.QLineEdit(self.widget)
  77.         font = QtGui.QFont()
  78.         font.setPointSize(10)
  79.         self.editSenha.setFont(font)
  80.         self.editSenha.setStyleSheet("background-color: rgb(255, 255, 255);")
  81.         self.editSenha.setEchoMode(QtWidgets.QLineEdit.Password)
  82.         self.editSenha.setObjectName("editSenha")
  83.         self.verticalLayout.addWidget(self.editSenha)
  84.  
  85.         self.pushButton.clicked.connect(self.click_btn_login)
  86.  
  87.         self.pushButton_2.clicked.connect(FormLogin.reject)
  88.  
  89.         self.retranslateUi(FormLogin)
  90.         QtCore.QMetaObject.connectSlotsByName(FormLogin)
  91.  
  92.  
  93.     def retranslateUi(self, FormLogin):
  94.         _translate = QtCore.QCoreApplication.translate
  95.         FormLogin.setWindowTitle(_translate("FormLogin", "Entrar"))
  96.         self.pushButton.setText(_translate("FormLogin", "Entrar"))
  97.         self.pushButton_2.setText(_translate("FormLogin", "Sair"))
  98.         self.label.setText(_translate("FormLogin", "Usu├írio:"))
  99.         self.label_2.setText(_translate("FormLogin", "Senha:"))
  100.  
  101.  
  102. if __name__ == '__main__':
  103.     import sys
  104.     app = QApplication(sys.argv)
  105.     tela = QDialog()
  106.     ui = Ui_FormLogin()
  107.     ui.setupUi(tela)
  108.     tela.show()
  109.     sys.exit(app.exec_())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top