Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.83 KB | None | 0 0
  1. import sys
  2. from PyQt4 import QtGui, QtCore
  3.  
  4. class Window (QtGui.QMainWindow):
  5.  
  6.     def __init__(self):
  7.         super (Window, self). __init__()
  8.         self.setGeometry(400, 250, 500, 200)
  9.         self.setWindowTitle("Login")
  10.        
  11.         self.home()
  12.  
  13.     def home (self):
  14.      
  15.         lblUser = QtGui.QLabel("Username", self)
  16.         lblUser.setStyleSheet('font: 13pt Arial')
  17.         lblUser.move(100, 70)
  18.  
  19.         lineUser = QtGui.QLineEdit(self)
  20.         lineUser.setStyleSheet('font: 11pt Arial')
  21.         lineUser.move(190, 73)
  22.         lineUser.resize(150, 20)
  23.  
  24.         lblPass = QtGui.QLabel("Password", self)
  25.         lblPass.setStyleSheet('font: 13pt Arial')
  26.         lblPass.move(100, 100)
  27.  
  28.         linePass = QtGui.QLineEdit(self)
  29.         linePass.setStyleSheet('font: 11pt Arial')
  30.         linePass.setEchoMode(QtGui.QLineEdit.Password)
  31.         linePass.move(190, 103)
  32.         linePass.resize(150, 20)
  33.  
  34.         btnLog = QtGui.QPushButton("Login", self)
  35.         btnLog.setStyleSheet('font: 11pt Arial')
  36.         btnLog.clicked.connect(self.Login)
  37.         btnLog.move(100, 140)
  38.  
  39.         self.show()
  40.  
  41.     def Quit(self):
  42.         choice = QtGui.QMessageBox.question(self, 'Quit Application',
  43.                                             "Are you sure you want to quit?",
  44.                                             QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
  45.         if choice == QtGui.QMessageBox.Yes:
  46.                 sys.exit()
  47.         else:
  48.                 pass
  49.  
  50.     def Login(self):
  51.        
  52.         if (lineUser.text() == 'admin' and
  53.             linePass.text() == '123'):
  54.             self.accept()
  55.         else:
  56.             QtGui.QMessageBox.warning(self, "Incorrect Username or Password")
  57.        
  58. def run():
  59.     app = QtGui.QApplication(sys.argv)
  60.     Gui = Window()
  61.     sys.exit(app.exec_())
  62.  
  63. run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement