-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
95 lines (83 loc) · 3.11 KB
/
main.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import sys
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QDialog, QApplication, QWidget,QMainWindow,QMessageBox
import sqlite3
from PyQt5 import (QtWidgets, uic, QtCore, QtGui)
import victoria
class main(QMainWindow):
def __init__(self):
super(main,self).__init__()
uic.loadUi("main.ui",self)
self.setWindowTitle("Victoria")
self.listen.clicked.connect(self.list)
self.Exit.clicked.connect(self.exit)
def list(self):
victoria.main()
def exit(self):
exit()
class Login(QDialog):
def __init__(self):
super(Login,self).__init__()
loadUi("login.ui",self)
self.setWindowTitle("Victoria - Login")
self.login.clicked.connect(self.loginCheck)
self.sign.clicked.connect(self.signCheck)
self.label_3.show()
self.password.setEchoMode(QtWidgets.QLineEdit.Password)
def signCheck(self):
sign = Sign()
widget = QtWidgets.QStackedWidget()
widget.addWidget(sign)
widget.setFixedHeight(254)
widget.setFixedWidth(484)
widget.setWindowTitle("Victoria - Sign")
widget.setCurrentIndex(widget.currentIndex()+1)
def loginCheck(self):
username = self.username.text()
password = self.password.text()
connection = sqlite3.connect("login.db")
result = connection.execute("SELECT * FROM USERS WHERE USERNAME= ? AND PASSWORD = ?",(username,password))
if (len(result.fetchall())>0):
mai1n = main()
widget.addWidget(mai1n)
widget.setFixedHeight(154)
widget.setFixedWidth(436)
widget.setWindowTitle("Victoria")
widget.setCurrentIndex(widget.currentIndex()+1)
else:
self.showMessageBox("Warning","Invalid Username or Password")
def showMessageBox(self,title,message):
msgBox = QMessageBox()
msgBox.setIcon(QMessageBox.Warning)
msgBox.setWindowTitle(title)
msgBox.setText(message)
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec_()
class Sign(QDialog):
def __init__(self):
super(Sign,self).__init__()
loadUi("sign.ui",self)
self.setWindowTitle("Victoria - Sign")
self.pushButton.clicked.connect(self.insertData)
self.password.setEchoMode(QtWidgets.QLineEdit.Password)
def insertData(self):
username = self.username.text()
email = self.email.text()
password = self.password.text()
connection = sqlite3.connect("login.db")
connection.execute("INSERT INTO USERS VALUES(?,?,?)",(username,email,password))
connection.commit()
connection.close()
log = Login()
widget.addWidget(log)
widget.setCurrentIndex(widget.currentIndex()+1)
app = QApplication(sys.argv)
login = Login()
widget = QtWidgets.QStackedWidget()
widget.addWidget(login)
widget.setWindowTitle("Victoria - Login")
widget.setFixedHeight(375)
widget.setFixedWidth(348)
widget.show()
app.exec()