-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.py
222 lines (188 loc) · 6.68 KB
/
profile.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
from tkinter import *
from tkinter import messagebox
from login import Login_page
from main import Main_page
from manage_profiles import UserProfile
class Profile_page():
def __init__(self):
# use db connection to load highscores for each game (based on username)
with open("./active_user.txt", "r") as f:
self.ACTIVE_USER = f.read()
# print(self.ACTIVE_USER)
self.userprofile = UserProfile()
self.active_user_data = self.userprofile.get_user_data(self.ACTIVE_USER)
# print(self.active_user_data)
def gui(self):
# design a profile page
self.main = Toplevel()
self.main.title("Profile")
self.main.geometry("900x600")
self.main.resizable(0, 0)
self.main.configure(background="white")
# bg image for tkinter window
self.window_bg = Label(self.main)
self.window_bg.place(relx=0, rely=0, width=900, height=600)
self.img = PhotoImage(file="./images/pages/profile.png")
self.window_bg.configure(image=self.img)
# Highscores
self.pong_game = Label(self.main)
self.pong_game.place(relx=0, rely=0, width=50, height=50)
self.pong_game.configure(
text="/",
background="#121212",
font=("Arial", 20),
foreground="white",
justify="left",
relief="flat",
bd=0
)
self.pong_game.place(x=426, y=140)
self.snake_game = Label(self.main)
self.snake_game.place(relx=0, rely=0, width=50, height=50)
self.snake_game.configure(
text=self.active_user_data[0][7],
background="#121212",
font=("Arial", 20),
foreground="white",
justify="left",
relief="flat",
bd=0
)
self.snake_game.place(x=692.7, y=140)
self.quiz_game = Label(self.main)
self.quiz_game.place(relx=0, rely=0, width=50, height=50)
self.quiz_game.configure(
text=self.active_user_data[0][8],
background="#121212",
font=("Arial", 20),
foreground="white",
justify="left",
relief="flat",
bd=0
)
self.quiz_game.place(x=426, y=300)
self.hangman_game = Label(self.main)
self.hangman_game.place(relx=0, rely=0, width=50, height=50)
self.hangman_game.configure(
text=self.active_user_data[0][10],
background="#121212",
font=("Arial", 20),
foreground="white",
justify="left",
relief="flat",
bd=0
)
self.hangman_game.place(x=692.7, y=300)
self.turtle_crossing_game = Label(self.main)
self.turtle_crossing_game.place(relx=0, rely=0, width=50, height=50)
self.turtle_crossing_game.configure(
text=self.active_user_data[0][9],
background="#121212",
font=("Arial", 20),
foreground="white",
justify="left",
relief="flat",
bd=0
)
self.turtle_crossing_game.place(x=558.7, y=465)
# profile image
self.profile_icon = Label(self.main)
self.profile_icon.place(relx=0, rely=0, width=130, height=125)
self.profile_img = PhotoImage(file="./images/profiles/profile_logo.png")
self.profile_icon.configure(image=self.profile_img)
self.profile_icon.place(x=112, y=100)
# profile details
self.name = Label(self.main)
self.name.place(relx=0, rely=0, width=235, height=30)
self.name.configure(
text=self.active_user_data[0][0],
background="#121212",
font="Arial",
foreground="white",
justify="left",
relief="flat",
bd=0
)
self.name.place(x=70, y=250)
self.username = Label(self.main)
self.username.place(relx=0, rely=0, width=235, height=30)
self.username.configure(
text=self.active_user_data[0][1],
background="#121212",
font="Arial",
foreground="white",
justify="left",
relief="flat",
bd=0
)
self.username.place(x=70, y=290)
self.email = Label(self.main)
self.email.place(relx=0, rely=0, width=235, height=30)
self.email.configure(
text=self.active_user_data[0][3],
background="#121212",
font="Arial",
foreground="white",
justify="left",
relief="flat",
bd=0
)
self.email.place(x=70, y=330)
self.dob = Label(self.main)
self.dob.place(relx=0, rely=0, width=235, height=30)
self.dob.configure(
text=self.active_user_data[0][5],
background="#121212",
font="Arial",
foreground="white",
justify="left",
relief="flat",
bd=0
)
self.dob.place(x=70, y=370)
# btn for profile
self.delete_btn = Button(self.main)
self.delete_img = PhotoImage(file="./images/buttons/delete_btn.png")
self.delete_btn.configure(
text="Update",
image=self.delete_img,
bg="#121212",
fg="red",
borderwidth="0",
cursor="hand2",
font=("Arial", 20),
command=self.delete_profile
)
self.delete_btn.place(x=119, y=420)
self.logout_btn = Button(self.main)
self.logout_img = PhotoImage(file="./images/buttons/logout_btn.png")
self.logout_btn.configure(
text="Logout",
image=self.logout_img,
bg="#121212",
fg="red",
borderwidth="0",
cursor="hand2",
font=("Arial", 20),
command=self.logout
)
self.logout_btn.place(x=113, y=480)
self.main.protocol("WM_DELETE_WINDOW", self.confirm_exit)
# self.main.mainloop()
# Helper function
def delete_profile(self):
if messagebox.askyesno("Confirmation", "Are you sure you want to delete your profile? \nAll your data will be lost forever."):
self.userprofile.delete_user(self.ACTIVE_USER)
# print(self.ACTIVE_USER)
self.main.destroy()
messagebox.showinfo("Thank you", "Thank you for playing Game Deck.")
Login_page().gui()
def logout(self):
if messagebox.askyesno("Logout", "Are you sure you want to logout?"):
self.main.destroy()
Login_page().gui()
def confirm_exit(self):
self.main.destroy()
Main_page().gui()
# demo = Profile_page()
# demo.gui()