Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PyQt4 import QtGui, QtCore
- class Window (QtGui.QMainWindow):
- def __init__(self):
- super (Window, self). __init__()
- self.setGeometry(400, 250, 500, 200)
- self.setWindowTitle("Login")
- self.home()
- def home (self):
- lblUser = QtGui.QLabel("Username", self)
- lblUser.setStyleSheet('font: 13pt Arial')
- lblUser.move(100, 70)
- lineUser = QtGui.QLineEdit(self)
- lineUser.setStyleSheet('font: 11pt Arial')
- lineUser.move(190, 73)
- lineUser.resize(150, 20)
- lblPass = QtGui.QLabel("Password", self)
- lblPass.setStyleSheet('font: 13pt Arial')
- lblPass.move(100, 100)
- linePass = QtGui.QLineEdit(self)
- linePass.setStyleSheet('font: 11pt Arial')
- linePass.setEchoMode(QtGui.QLineEdit.Password)
- linePass.move(190, 103)
- linePass.resize(150, 20)
- btnLog = QtGui.QPushButton("Login", self)
- btnLog.setStyleSheet('font: 11pt Arial')
- btnLog.clicked.connect(self.Login)
- btnLog.move(100, 140)
- self.show()
- def Quit(self):
- choice = QtGui.QMessageBox.question(self, 'Quit Application',
- "Are you sure you want to quit?",
- QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
- if choice == QtGui.QMessageBox.Yes:
- sys.exit()
- else:
- pass
- def Login(self):
- if (lineUser.text() == 'admin' and
- linePass.text() == '123'):
- self.accept()
- else:
- QtGui.QMessageBox.warning(self, "Incorrect Username or Password")
- def run():
- app = QtGui.QApplication(sys.argv)
- Gui = Window()
- sys.exit(app.exec_())
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement