SHARE
TWEET

Untitled

a guest Aug 12th, 2016 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Form implementation generated from reading ui file 'Login.ui'
  4. #
  5. # Created by: PyQt4 UI code generator 4.11.4
  6. #
  7. # WARNING! All changes made in this file will be lost!
  8. import sys
  9. import DBmanager as db
  10. from PyQt4 import QtCore, QtGui
  11. from newuser import Ui_Form
  12. from createprofile import Ui_StudentLogin
  13.  
  14. try:
  15.     _fromUtf8 = QtCore.QString.fromUtf8
  16. except AttributeError:
  17.     def _fromUtf8(s):
  18.         return s
  19.  
  20. try:
  21.     _encoding = QtGui.QApplication.UnicodeUTF8
  22.     def _translate(context, text, disambig):
  23.         return QtGui.QApplication.translate(context, text, disambig, _encoding)
  24. except AttributeError:
  25.     def _translate(context, text, disambig):
  26.         return QtGui.QApplication.translate(context, text, disambig)
  27.  
  28. #######SIGN IN/ LOG IN#################################################################################################
  29.  
  30. class Ui_Login(QtGui.QWidget):
  31.     def __init__(self):
  32.         QtGui.QWidget.__init__(self)
  33.         self.dbu = db.DatabaseUtility('UsernamePassword_DB', 'masterTable')
  34.         self.setupUi(self)
  35.         self.confirm = None
  36.  
  37.     def setupUi(self, Login):
  38.         Login.setObjectName(_fromUtf8("Form"))
  39.         Login.resize(400, 301)
  40.         self.label = QtGui.QLabel(Login)
  41.         self.label.setGeometry(QtCore.QRect(60, 60, 71, 21))
  42.         font = QtGui.QFont()
  43.         font.setBold(True)
  44.         font.setWeight(75)
  45.         self.label.setFont(font)
  46.         self.label.setObjectName(_fromUtf8("label"))
  47.         self.label_2 = QtGui.QLabel(Login)
  48.         self.label_2.setGeometry(QtCore.QRect(60, 120, 81, 21))
  49.         font = QtGui.QFont()
  50.         font.setBold(True)
  51.         font.setWeight(75)
  52.         self.label_2.setFont(font)
  53.         self.label_2.setObjectName(_fromUtf8("label_2"))
  54.         self.userName = QtGui.QLineEdit(Login)
  55.         self.userName.setGeometry(QtCore.QRect(140, 60, 151, 21))
  56.         self.userName.setObjectName(_fromUtf8("userName"))
  57.  
  58.         self.passWord = QtGui.QLineEdit(Login)
  59.         self.passWord.setGeometry(QtCore.QRect(140, 120, 151, 21))
  60.         self.passWord.setObjectName(_fromUtf8("passWord"))
  61.  
  62.         self.label_3 = QtGui.QLabel(Login)
  63.         self.label_3.setGeometry(QtCore.QRect(160, 10, 131, 21))
  64.         font = QtGui.QFont()
  65.         font.setPointSize(10)
  66.         font.setBold(True)
  67.         font.setWeight(75)
  68.         self.label_3.setFont(font)
  69.         self.label_3.setObjectName(_fromUtf8("label_3"))
  70.  
  71.         self.loginButton1 = QtGui.QPushButton(Login)
  72.         self.loginButton1.setGeometry(QtCore.QRect(40, 210, 75, 23))
  73.         font = QtGui.QFont()
  74.         font.setBold(True)
  75.         font.setWeight(75)
  76.         self.loginButton1.setFont(font)
  77.         self.loginButton1.setObjectName(_fromUtf8("loginButton1"))
  78.         self.loginButton1.clicked.connect(self.login_Button1)
  79.  
  80.         self.signUpButton = QtGui.QPushButton(Login)
  81.         self.signUpButton.setGeometry(QtCore.QRect(160, 210, 75, 23))
  82.         font = QtGui.QFont()
  83.         font.setBold(True)
  84.         font.setWeight(75)
  85.         self.signUpButton.setFont(font)
  86.         self.signUpButton.setObjectName(_fromUtf8("signUpButton"))
  87.         self.signUpButton.clicked.connect(self.signUp_Button)
  88.  
  89.         self.cancel1 = QtGui.QPushButton(Login)
  90.         self.cancel1.setGeometry(QtCore.QRect(280, 210, 75, 23))
  91.         font = QtGui.QFont()
  92.         font.setBold(True)
  93.         font.setWeight(75)
  94.         self.cancel1.setFont(font)
  95.         self.cancel1.setObjectName(_fromUtf8("cancel1"))
  96.         self.connect(self, QtCore.SIGNAL('triggered()'), self.cancel_1)
  97.  
  98.         self.retranslateUi(Login)
  99.         QtCore.QMetaObject.connectSlotsByName(Login)
  100.  
  101.     def retranslateUi(self, Login):
  102.         Login.setWindowTitle(_translate("Form", "Login", None))
  103.         self.label.setText(_translate("Form", "USERNAME", None))
  104.         self.label_2.setText(_translate("Form", "PASSWORD", None))
  105.         self.label_3.setText(_translate("Form", "LOGIN PAGE", None))
  106.         self.loginButton1.setText(_translate("Form", "LOGIN", None))
  107.         self.signUpButton.setText(_translate("Form", "SIGN UP", None))
  108.         self.cancel1.setText(_translate("Form", "CANCEL", None))
  109.  
  110.     @QtCore.pyqtSignature("on_cancel1_clicked()")
  111.     def cancel_1(self):
  112.         self.close()
  113.  
  114.     @QtCore.pyqtSignature("on_loginButton1_clicked()")
  115.     def login_Button1(self):
  116.         username = self.userName.text()
  117.         password = self.passWord.text()
  118.         if not username:
  119.             QtGui.QMessageBox.warning(self, 'Guess What?', 'Username Missing!')
  120.         elif not password:
  121.             QtGui.QMessageBox.warning(self, 'Guess What?', 'Password Missing!')
  122.         else:
  123.             self.AttemptLogin(username, password)
  124.  
  125.     def AttemptLogin(self, username, password):
  126.         t = self.dbu.GetTable()
  127.         print (t)
  128.         for col in t:
  129.             if username == col[1]:
  130.                 if password == col[2]:
  131.                     QtGui.QMessageBox.information(self, 'WELCOME', 'Success!!')
  132.                     self.createProfilePage()
  133.                     self.close()
  134.                 else:
  135.                     QtGui.QMessageBox.warning(self, 'OOPS SORRY!', 'Password incorrect...')
  136.                 return
  137.  
  138.  
  139.     def createProfilePage(self):
  140.         self.createprofile = Ui_StudentLogin()
  141.         self.createprofile.show()
  142.  
  143.  
  144.     @QtCore.pyqtSignature("on_signUpButton_clicked()")
  145.     def signUp_Button(self):
  146.         self.newuser = Ui_Form(self)
  147.         self.newuser.show()
  148.  
  149. #######SIGN UP/ CREATE NEW USER#################################################################################################
  150.  
  151.  
  152. class Ui_Form(QtGui.QWidget):
  153.     def __init__(self,dbu):
  154.         QtGui.QWidget.__init__(self)
  155.         self.setupUi(self)
  156.         self.dbu = dbu
  157.  
  158.     def setupUi(self, Form):
  159.         Form.setObjectName(_fromUtf8("Form"))
  160.         Form.resize(400, 300)
  161.  
  162.         self.label = QtGui.QLabel(Form)
  163.         self.label.setGeometry(QtCore.QRect(60, 70, 51, 16))
  164.         font = QtGui.QFont()
  165.         font.setBold(True)
  166.         font.setWeight(75)
  167.         self.label.setFont(font)
  168.         self.label.setObjectName(_fromUtf8("label"))
  169.  
  170.         self.nameGet = QtGui.QLineEdit(Form)
  171.         self.nameGet.setGeometry(QtCore.QRect(120, 70, 191, 21))
  172.         self.nameGet.setObjectName(_fromUtf8("nameGet"))
  173.  
  174.         self.label_2 = QtGui.QLabel(Form)
  175.         self.label_2.setGeometry(QtCore.QRect(50, 120, 46, 13))
  176.         font = QtGui.QFont()
  177.         font.setBold(True)
  178.         font.setWeight(75)
  179.         self.label_2.setFont(font)
  180.         self.label_2.setObjectName(_fromUtf8("label_2"))
  181.  
  182.         self.label_3 = QtGui.QLabel(Form)
  183.         self.label_3.setGeometry(QtCore.QRect(30, 170, 71, 16))
  184.         font = QtGui.QFont()
  185.         font.setBold(True)
  186.         font.setWeight(75)
  187.         self.label_3.setFont(font)
  188.         self.label_3.setObjectName(_fromUtf8("label_3"))
  189.  
  190.         self.regNoGet = QtGui.QLineEdit(Form)
  191.         self.regNoGet.setGeometry(QtCore.QRect(120, 120, 191, 21))
  192.         self.regNoGet.setObjectName(_fromUtf8("regNoGet"))
  193.  
  194.         self.passWordGet = QtGui.QLineEdit(Form)
  195.         self.passWordGet.setGeometry(QtCore.QRect(120, 170, 191, 21))
  196.         self.passWordGet.setObjectName(_fromUtf8("passWordGet"))
  197.  
  198.         self.label_4 = QtGui.QLabel(Form)
  199.         self.label_4.setGeometry(QtCore.QRect(100, 20, 181, 21))
  200.         font = QtGui.QFont()
  201.         font.setPointSize(10)
  202.         font.setBold(True)
  203.         font.setWeight(75)
  204.         self.label_4.setFont(font)
  205.         self.label_4.setObjectName(_fromUtf8("label_4"))
  206.  
  207.         self.nextButton = QtGui.QPushButton(Form)
  208.         self.nextButton.setGeometry(QtCore.QRect(140, 250, 75, 23))
  209.         font = QtGui.QFont()
  210.         font.setBold(True)
  211.         font.setWeight(75)
  212.         self.nextButton.setFont(font)
  213.         self.nextButton.setObjectName(_fromUtf8("nextButton"))
  214.         self.nextButton.clicked.connect(self.next_Button)
  215.  
  216.  
  217.         self.cancelButton = QtGui.QPushButton(Form)
  218.         self.cancelButton.setGeometry(QtCore.QRect(260, 250, 75, 23))
  219.         font = QtGui.QFont()
  220.         font.setBold(True)
  221.         font.setWeight(75)
  222.         self.cancelButton.setFont(font)
  223.         self.cancelButton.setObjectName(_fromUtf8("cancelButton"))
  224.         self.cancelButton.clicked.connect(self.cancel_Button)
  225.  
  226.         self.retranslateUi(Form)
  227.         QtCore.QMetaObject.connectSlotsByName(Form)
  228.  
  229.     def retranslateUi(self, Form):
  230.         Form.setWindowTitle(_translate("Form", "New User", None))
  231.         self.label.setText(_translate("Form", "NAME", None))
  232.         self.label_2.setText(_translate("Form", "REG. NO", None))
  233.         self.label_3.setText(_translate("Form", "PASSWORD", None))
  234.         self.label_4.setText(_translate("Form", "            CREATE NEW USER", None))
  235.         self.nextButton.setText(_translate("Form", "SUBMIT", None))
  236.         self.cancelButton.setText(_translate("Form", "CANCEL", None))
  237.  
  238.     @QtCore.pyqtSignature("on_cancelButton_clicked()")
  239.     def cancel_Button(self):
  240.         self.close()
  241.  
  242.  
  243.     @QtCore.pyqtSignature("on_nextButton_clicked()")
  244.     def next_Button(self):
  245.         username = self.nameGet.text()
  246.         password = self.passWordGet.text()
  247.         regno = self.regNoGet.text()
  248.         if not username:
  249.             QtGui.QMessageBox.warning(self, 'Warning', 'Username Missing')
  250.         elif not password:
  251.             QtGui.QMessageBox.warning(self, 'Warning!', 'Password Missing')
  252.         elif not regno:
  253.             QtGui.QMessageBox.warning(self, 'Warning!', 'RegNo Missing')
  254.         else:
  255.             t = self.dbu.GetTable()
  256.             print (t)
  257.             for col in t:
  258.                 if username == col[1]:
  259.                     QtGui.QMessageBox.warning(self, 'Dang it!', 'Username Taken. :(')
  260.             else:
  261.                 self.dbu.AddEntryToTable (username, password, regno)
  262.                 QtGui.QMessageBox.information(self, 'Awesome!!', 'User Added SUCCESSFULLY!')
  263.                 self.close()
  264.  
  265.  
  266.  
  267. ##    def createProfileWindow(self):
  268. ##        self.createprofile = Ui_StudentLogin()
  269. ##        self.createprofile.show()
  270. ##
  271. ##    def generate_report(self):
  272. ##        data_line1 = self.nameGet.displayText()
  273. ##        data_line2 = self.regNoGet.displayText()
  274. ##        data_line3 = self.passWordGet.displayText()
  275. ##        print data_line1
  276. ##        print data_line2
  277. ##        print data_line3
  278. ##        
  279.  
  280.  
  281.  
  282.  
  283. if __name__ == '__main__':
  284.     app = QtGui.QApplication(sys.argv)
  285.     ex = Ui_Login()
  286.     ex.show()
  287.     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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top