-
Notifications
You must be signed in to change notification settings - Fork 0
/
login1.py
70 lines (54 loc) · 2 KB
/
login1.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
import sys
from PyQt5 import QtWidgets, QtMultimedia, uic, QtCore
import mysql.connector
import register
import dashboard
db_connection = mysql.connector.connect(
host="localhost",
user="root",
passwd="root",
database="Edudroid"
)
class loginClass(QtWidgets.QDialog):
switch_next_window=QtCore.pyqtSignal()
def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent)
self.ui = uic.loadUi(os.path.join(os.path.dirname(__file__), "Layout/login_new.ui"),self)
self.button1 = self.findChild(QtWidgets.QPushButton, 'register_2')
self.button2 = self.findChild(QtWidgets.QPushButton, 'login')
self.button3 = self.findChild(QtWidgets.QPushButton, 'guest')
self.email = self.findChild(QtWidgets.QLineEdit, 'email')
self.passwd = self.findChild(QtWidgets.QLineEdit, 'passwd')
self.button1.clicked.connect(self.register)
self.button2.clicked.connect(self.loginFun)
self.button3.clicked.connect(self.guestFun)
def register(self):
print("register")
register.RegisterClass.startWin(self)
self.close()
def loginFun(self):
useremail=self.email.text()
userpasswd=self.passwd.text()
query='select * from Student where student_email = "'+useremail+'" and student_password = "'+userpasswd+'"'
my_database = db_connection.cursor()
my_database.execute(query)
output = my_database.fetchall()
if my_database.rowcount>0:
print("logged in")
self.close()
dashboard.dashboard.startWin(self)
else:
print("incorrect password")
def guestFun(self):
print("guest")
dashboard.dashboard.startWin(self)
self.hide()
def startWin(self):
window = loginClass(self)
window.showFullScreen()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
w = loginClass()
w.showFullScreen()
sys.exit(app.exec())