-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
182 lines (152 loc) · 6.07 KB
/
main.py
File metadata and controls
182 lines (152 loc) · 6.07 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
from PyQt5.QtWidgets import QDialog, QApplication
from PyQt5.uic import loadUi
from MplChart_reg import *
import sys
class WelcomeScreen(QDialog):
def __init__(self):
super(WelcomeScreen, self).__init__()
Welcome_sc = "Screen_template\_WelcomeScreen.ui"
try:
loadUi(Welcome_sc, self)
except FileNotFoundError:
msg = "Unfortunately, file " + Welcome_sc + " not found."
print(msg)
exit(1)
self.Login.clicked.connect(self.gotologin)
self.Register.clicked.connect(self.gotoregister)
@staticmethod
def gotologin():
login = LoginScreen()
widget.addWidget(login)
widget.setCurrentIndex(widget.currentIndex() + 1)
@staticmethod
def gotoregister():
register = RegisterScreen()
widget.addWidget(register)
widget.setCurrentIndex(widget.currentIndex() + 1)
class RegisterScreen(QDialog):
def __init__(self):
super(RegisterScreen, self).__init__()
Register_sc = "Screen_template\_RegisterScreen.ui"
try:
loadUi(Register_sc, self)
except FileNotFoundError:
msg = "Unfortunately, file " + Register_sc + " not found."
print(msg)
exit(1)
self.Back.clicked.connect(self.gotowelcome)
self.Confirm.clicked.connect(self.gotomenu)
self.Password.setEchoMode(QtWidgets.QLineEdit.Password)
self.Confirm_password.setEchoMode(QtWidgets.QLineEdit.Password)
def gotomenu(self):
email = self.Email_field.text()
first_name = self.First_name.text()
password = self.Password.text()
confirm_password = self.Confirm_password.text()
if len(email) == 0 or len(password) == 0 or len(first_name) == 0 or len(confirm_password) == 0:
self.error.setText("Please input all fields.")
else:
if password != confirm_password:
self.error.setText("Passwords are not the same.")
else:
data_login = "Data\DataSet.db"
con = sqlite3.connect(data_login)
cur = con.cursor()
data = [(email, password, first_name)]
cur.executemany("INSERT INTO User_Info VALUES(?, ?, ?)", data)
con.commit()
con.close()
login = LoginScreen()
widget.addWidget(login)
widget.setCurrentIndex(widget.currentIndex() + 1)
@staticmethod
def gotowelcome():
welcome_back = WelcomeScreen()
widget.addWidget(welcome_back)
widget.setCurrentIndex(widget.currentIndex() + 1)
class LoginScreen(QDialog):
def __init__(self):
super(LoginScreen, self).__init__()
Login_sc = "Screen_template\_LoginScreen.ui"
try:
loadUi(Login_sc, self)
except FileNotFoundError:
msg = "Unfortunately, file " + Login_sc + " not found."
print(msg)
exit(1)
self.Back_button.clicked.connect(self.gotowelcome)
self.Confirm.clicked.connect(self.gotomenu)
self.Password_field.setEchoMode(QtWidgets.QLineEdit.Password)
def gotomenu(self):
email = self.Email_field.text()
password = self.Password_field.text()
if len(email) == 0 or len(password) == 0:
self.error.setText("Please input all fields.")
else:
data_login = "Data\DataSet.db"
con = sqlite3.connect(data_login)
cur = con.cursor()
for row in cur.execute("SELECT Password FROM User_Info;"):
for rows in row:
if password in rows:
self.error.setText("Successfully logged in.")
con.commit()
con.close()
Menu = MenuScreen()
widget.addWidget(Menu)
widget.setCurrentIndex(widget.currentIndex() + 1)
return 0
else:
self.error.setText("Invalid E-mail or password")
@staticmethod
def gotowelcome():
welcome_back = WelcomeScreen()
widget.addWidget(welcome_back)
widget.setCurrentIndex(widget.currentIndex() + 1)
class MenuScreen(QDialog):
def __init__(self):
super(MenuScreen, self).__init__()
Menu_sc = "Screen_template\_MenuScreen.ui"
try:
loadUi(Menu_sc, self)
except FileNotFoundError:
msg = "Unfortunately, file " + Menu_sc + " not found."
print(msg)
exit(1)
self.SW = None
self.stackedWidget.setCurrentWidget(self.Dashboard)
self.analysis.clicked.connect(self.gotoanalysis)
self.calendar.clicked.connect(self.gotocalendar)
self.back.clicked.connect(self.goback)
self.log_out.clicked.connect(self.gotowelcome)
def gotoanalysis(self):
self.stackedWidget.setCurrentWidget(self.Analysis)
self.Create.clicked.connect(self.gotochart)
def gotocalendar(self):
self.stackedWidget.setCurrentWidget(self.Calendar)
def goback(self):
self.stackedWidget.setCurrentWidget(self.Dashboard)
def gotochart(self):
self.wait.setText("Please wait ...")
self.SW = SecondWindow()
self.SW.resize(930, 640)
self.SW.show()
@staticmethod
def gotowelcome():
welcome_back = WelcomeScreen()
widget.addWidget(welcome_back)
widget.setCurrentIndex(widget.currentIndex() + 1)
@staticmethod
def gotomenu():
Menu = MenuScreen()
widget.addWidget(Menu)
widget.setCurrentIndex(widget.currentIndex() + 1)
if __name__ == "__main__":
app = QApplication(sys.argv)
welcome = WelcomeScreen()
widget = QtWidgets.QStackedWidget()
widget.addWidget(welcome)
widget.setFixedHeight(540)
widget.setFixedWidth(930)
widget.show()
sys.exit(app.exec_())