-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
45 lines (33 loc) · 1.2 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from PyQt4 import QtGui
# from mainwindow import Ui_MainWindow
class Login(QtGui.QDialog):
def __init__(self, parent=None):
super(Login, self).__init__(parent)
self.textName = QtGui.QLineEdit(self)
self.textPass = QtGui.QLineEdit(self)
self.buttonLogin = QtGui.QPushButton('Login', self)
self.buttonLogin.clicked.connect(self.handleLogin)
layout = QtGui.QVBoxLayout(self)
layout.addWidget(self.textName)
layout.addWidget(self.textPass)
layout.addWidget(self.buttonLogin)
def handleLogin(self):
if (self.textName.text() == 'foo' and
self.textPass.text() == 'bar'):
self.accept()
else:
QtGui.QMessageBox.warning(
self, 'Error', 'Bad user or password')
class Window(QtGui.QMainWindow):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
# self.ui = Ui_MainWindow()
# self.ui.setupUi(self)
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
login = Login()
if login.exec_() == QtGui.QDialog.Accepted:
window = Window()
window.show()
sys.exit(app.exec_())