text: # -*- coding: utf-8 -*-
  
  # Form implementation generated from reading ui file 'login.ui'
  #
  # Created by: PyQt5 UI code generator 5.15.4
  #
  # WARNING: Any manual changes made to this file will be lost when pyuic5 is
  # run again.  Do not edit this file unless you know what you are doing.
  
  
  from PyQt5 import QtCore, QtGui, QtWidgets
  from PyQt5.QtWidgets import QMessageBox
  import sys
  import mysql.connector as mc
  from main import MainWindow
  
  mydb = mc.connect(
      host="localhost",
      user="root",
      passwd="@ADS5188y",
      database="license_plate_rec"
  )
  
  
  class Ui_Form(object):
      def show_popup(self,message,title,status):
          msg= QMessageBox()
          msg.setWindowTitle(title)
          msg.setText(message)
  
          if status == "Failed":
              msg.setIcon(QMessageBox.Critical)
              msg.setStandardButtons(QMessageBox.Retry|QMessageBox.Cancel)
  
          elif status == "Success":
              msg.setIcon(QMessageBox.Information)
  
         
  
          x= msg.exec_()
  
      def login(self):
          try:
              username = self.lineEdit_3.text()
              passwd = self.lineEdit_2.text()
  
              mycursor = mydb.cursor()
              query = "SELECT * FROM login WHERE BINARY username = '%s' AND BINARY password = '%s'" % (username, passwd)
              mycursor.execute(query)
              result = mycursor.fetchone()
  
              if result == None:
                  print('Login Failed')
                  self.show_popup("Login Failed, Check Username and Password", "Login Failed", 'Failed')
              else:
                  self.show_popup("Login Success, Welcome!!", "Success", 'Success')
                  # self.close()
                  Form.setVisible(False)
                  MainWindow().show()
          except mc.Error as e:
              print('failed')
  
      def setupUi(self, Form):
          Form.setObjectName("Form")
          Form.resize(370, 553)
          font = QtGui.QFont()
          font.setFamily("Helvetica")
          font.setPointSize(12)
          Form.setFont(font)
          Form.setWindowFlags(QtCore.Qt.FramelessWindowHint)
          Form.setAttribute(QtCore.Qt.WA_TranslucentBackground)
          self.widget = QtWidgets.QWidget(Form)
          self.widget.setGeometry(QtCore.QRect(20, 20, 320, 500))
          self.widget.setObjectName("widget")
          self.label = QtWidgets.QLabel(self.widget)
          self.label.setGeometry(QtCore.QRect(0, 119, 320, 351))
          self.label.setStyleSheet("background-color:#14213D;\n"
                                   "border-radius:5px;\n"
                                   "")
          self.label.setText("")
          self.label.setObjectName("label")
          self.lineEdit_2 = QtWidgets.QLineEdit(self.widget)
          self.lineEdit_2.setGeometry(QtCore.QRect(50, 310, 221, 30))
          font = QtGui.QFont()
          font.setFamily("Helvetica")
          font.setPointSize(10)
          font.setBold(True)
          font.setWeight(75)
          self.lineEdit_2.setFont(font)
          self.lineEdit_2.setStyleSheet("background-color: transparent;\n"
                                        "border:transparent;\n"
                                        "border-bottom: 2px solid #e5e5e5;\n"
                                        "color: #e5e5e5;\n"
                                        "padding-bottom:4px;")
          self.lineEdit_2.setText("")
          self.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password)
          self.lineEdit_2.setObjectName("lineEdit_2")
          self.pushButton = QtWidgets.QPushButton(self.widget)
          self.pushButton.setGeometry(QtCore.QRect(110, 360, 101, 31))
          self.pushButton.clicked.connect(self.login)
          font = QtGui.QFont()
          font.setFamily("Helvetica")
          font.setPointSize(12)
          font.setBold(True)
          font.setItalic(False)
          font.setWeight(75)
          self.pushButton.setFont(font)
          self.pushButton.setStyleSheet("QPushButton#pushButton{\n"
                                        "background-color:#fca311;\n"
                                        "border-radius: 8px;\n"
                                        "color: #e5e5e5;\n"
                                        "border:none;\n"
                                        "outline:none;\n"
                                        "}\n"
                                        "\n"
                                        "QPushButton#pushButton:pressed{\n"
                                        "background-color:#fca311;\n"
                                        "border-radius: 8px;\n"
                                        "color: #e5e5e5;\n"
                                        "border:none;\n"
                                        "outline:none;\n"
                                        "transform:translate (5px, 5px);\n"
                                        "}\n"
                                        "")
          self.pushButton.setObjectName("pushButton")
          self.lineEdit_3 = QtWidgets.QLineEdit(self.widget)
          self.lineEdit_3.setGeometry(QtCore.QRect(50, 260, 221, 30))
          font = QtGui.QFont()
          font.setFamily("Helvetica")
          font.setPointSize(10)
          font.setBold(True)
          font.setWeight(75)
          self.lineEdit_3.setFont(font)
          self.lineEdit_3.setStyleSheet("background-color: transparent;\n"
                                        "border:transparent;\n"
                                        "border-bottom: 2px solid #e5e5e5;\n"
                                        "color: #e5e5e5;\n"
                                        "padding-bottom:4px;")
          self.lineEdit_3.setText("")
          self.lineEdit_3.setObjectName("lineEdit_3")
          self.label_2 = QtWidgets.QLabel(self.widget)
          self.label_2.setGeometry(QtCore.QRect(50, 190, 241, 41))
          font = QtGui.QFont()
          font.setPointSize(22)
          self.label_2.setFont(font)
          self.label_2.setStyleSheet("color: #e5e5e5;")
          self.label_2.setObjectName("label_2")
  
          self.retranslateUi(Form)
          QtCore.QMetaObject.connectSlotsByName(Form)
  
      def retranslateUi(self, Form):
          _translate = QtCore.QCoreApplication.translate
          Form.setWindowTitle(_translate("Form", "Form"))
          self.lineEdit_2.setPlaceholderText(_translate("Form", "Password:"))
          self.pushButton.setText(_translate("Form", "Login"))
          self.lineEdit_3.setPlaceholderText(_translate("Form", "Username:"))
          self.label_2.setText(_translate("Form", "Login to Continue"))
  
  
  if __name__ == "__main__":
      app = QtWidgets.QApplication(sys.argv)
      Form = QtWidgets.QWidget()
      ui = Ui_Form()
      ui.setupUi(Form)
      Form.show()
      sys.exit(app.exec_())
  