Skip to content

Commit fdf4595

Browse files
committed
GUI for Login Page Ready!!
1 parent bf87552 commit fdf4595

File tree

3 files changed

+139
-20
lines changed

3 files changed

+139
-20
lines changed

LoginPageGUI.py

Lines changed: 134 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,141 @@
11
from tkinter import *
2+
import pymongo
3+
myclient = pymongo.MongoClient(
4+
"mongodb+srv://CodingBlood:[email protected]/myFirstDatabase?retryWrites=true&w=majority")
5+
mydb = myclient["Chatbox"]
6+
mycol = mydb["UserDetails"]
27
def main():
3-
User_login = Tk()
4-
userid = StringVar()
5-
paswrd = StringVar()
68
def some():
9+
# global userid
10+
# global paswrd
711
name = userid.get()
812
pass_wrd = paswrd.get()
9-
print("The name is : " + name)
10-
print("The password is : " + pass_wrd)
13+
myquery = {"UName": name}
14+
mydoc = mycol.find(myquery)
15+
for x in mydoc:
16+
if x["UPassword"] == pass_wrd:
17+
print("Login Successful")
18+
# Button(root1, text="Login Successful Click To Proceed", width=100, height=2, bd=5,)
19+
else:
20+
print("Login Failed")
21+
# Button(root1, text="Login Failed Retry...", width=100, height=2, bd=5)
1122
userid.set("")
1223
paswrd.set("")
13-
User_login.title("Login")
14-
Label(User_login, text='UserName', width=50, height=2).grid(row=0, column=0)
15-
Label(User_login, text='Password', width=50, height=2).grid(row=1, column=0)
16-
e1 = Entry(User_login, bd=5, textvariable=userid)
17-
e2 = Entry(User_login, bd=5, textvariable=paswrd, show='*')
18-
login = Button(User_login, text='Login', command=some, width=100, height=2, bd=5)
19-
go_back = Button(User_login, text='Go Back', command=User_login.destroy, width=100, height=2, bd=5)
20-
e1.grid(row=0, column=1, padx=100, pady=4)
21-
e2.grid(row=1, column=1, padx=100, pady=4)
22-
login.grid(row=2, columnspan=2, padx=100, pady=4)
23-
go_back.grid(row=3, columnspan=2, padx=100, pady=4)
24-
User_login.mainloop()
24+
def switch():
25+
global btnState
26+
if btnState is True:
27+
# create animated Navbar closing:
28+
for x in range(301):
29+
navRoot.place(x=-x, y=0)
30+
topFrame.update()
31+
# resetting widget colors:
32+
brandLabel.config(bg="gray17", fg="green")
33+
homeLabel.config(bg=color["orange"])
34+
topFrame.config(bg=color["orange"])
35+
# root.config(bg="gray17")
36+
37+
# turning button OFF:
38+
btnState = False
39+
else:
40+
# make root dim:
41+
brandLabel.config(bg=color["nero"], fg="#5F5A33")
42+
# homeLabel.config(bg=color["nero"])
43+
topFrame.config(bg=color["nero"])
44+
root1.config(bg=color["nero"])
45+
46+
# created animated Navbar opening:
47+
for x in range(-300, 0):
48+
navRoot.place(x=x, y=0)
49+
topFrame.update()
50+
51+
# turing button ON:
52+
btnState = True
53+
root1 = Toplevel()
54+
root1.geometry("1300x700")
55+
color = {"nero": "#252726", "orange": "#FF8700", "darkorange": "#FE6101"}
56+
root1.title("Chat Box")
57+
# setting switch state:
58+
global btnState
59+
btnState = False
60+
# loading Navbar icon image:
61+
navIcon = PhotoImage(file="ham.png")
62+
closeIcon = PhotoImage(file="goback.png")
63+
login = PhotoImage(file=r"login.png", height=100, width=100)
64+
signup = PhotoImage(file=r"signup.png", height=100, width=105)
65+
find = PhotoImage(file=r"find.png", height=100, width=105)
66+
delete = PhotoImage(file=r"delete.png", height=100, width=100)
67+
photo1 = PhotoImage(file=r"heytest.png")
68+
canvas1 = Canvas(root1, width=400, height=400)
69+
canvas1.pack(fill="both", expand=True)
70+
canvas1.create_image(0, 0, image=photo1, anchor="nw")
71+
72+
# top Navigation bar:
73+
topFrame = Frame(root1, bg=color["orange"])
74+
canvas1.create_window(0, 0, anchor="nw", window=topFrame, width="1300", height="125")
75+
# topFrame.pack(side="top", fill=X)
76+
77+
# Header label text:
78+
homeLabel = Label(topFrame, text="Chat Box", font="Bahnschrift 95", bg=color["orange"], fg="gray17", height=2,
79+
padx=20)
80+
homeLabel.pack(side="right")
81+
82+
83+
84+
85+
86+
# Main label text:
87+
userid = StringVar()
88+
paswrd = StringVar()
89+
brandLabel = Label(root1, text="", font="System 30", bg="gray17", fg="green")
90+
brandLabel.place(x=100, y=250)
91+
b1 = Button(root1, text=' Login', bg=color["nero"], fg=color["orange"],
92+
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound=LEFT,
93+
anchor="nw", command=some)
94+
# canvas1.create_text(100, 245, "Username", width=50, height=1, fg=color["orange"])
95+
l1 = Entry(root1,font=('Malgun Gothic Semilight', 25, "bold"),bd=5, textvariable=userid)
96+
l2 = Entry(root1,font=('Malgun Gothic Semilight', 25, "bold"),bd=5, textvariable=paswrd, show='*')
97+
l3 = Label(root1, text='UserName', width=15, height=1, font=('Malgun Gothic Semilight', 25, "bold"),bd=5)
98+
l4 = Label(root1, text='Password', width=15, height=1, font=('Malgun Gothic Semilight', 25, "bold"),bd=5)
99+
# e1 = Entry(l1, bd=5)
100+
# e2 = Entry(l2, bd=5)
101+
canvas1.create_window(300, 495, anchor="nw", window=b1)
102+
canvas1.create_window(700, 245, anchor="nw", window=l1)
103+
canvas1.create_window(700, 370, anchor="nw", window=l2)
104+
canvas1.create_window(100, 245, anchor="nw", window=l3)
105+
canvas1.create_window(100, 370, anchor="nw", window=l4)
106+
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+
# Navbar button:
117+
navbarBtn = Button(topFrame, image=navIcon, bg=color["orange"], activebackground=color["orange"], bd=0, padx=20,
118+
command=switch)
119+
navbarBtn.place(x=10, y=10)
120+
121+
# setting Navbar frame:
122+
navRoot = Frame(root1, bg="gray17", height=1000, width=300)
123+
navRoot.place(x=-300, y=0)
124+
Label(navRoot, font="Bahnschrift 15", bg=color["orange"], fg="black", height=2, width=300, padx=20).place(x=0, y=0)
125+
126+
# set y-coordinate of Navbar widgets:
127+
y = 180
128+
# option in the navbar:
129+
options = ["Login", "Login Super User", "New User", "New Super User", "Find Friend By Id", "Delete account"]
130+
# Navbar Option Buttons:
131+
for i in range(6):
132+
Button(navRoot, text=options[i], font="BahnschriftLight 15", bg="gray17", fg=color["orange"],
133+
activebackground="gray17", activeforeground="green", bd=0).place(x=25, y=y)
134+
y += 40
135+
136+
# Navbar Close Button:
137+
closeBtn = Button(navRoot, image=closeIcon, bg=color["orange"], activebackground=color["orange"], bd=0,
138+
command=switch)
139+
closeBtn.place(x=150, y=10)
140+
141+
root1.mainloop()
2.36 KB
Binary file not shown.

main_gui.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def switch():
178178
# turing button ON:
179179
btnState = True
180180

181+
181182
from tkinter import *
182183
root =Tk()
183184
root.geometry("1300x700")
@@ -213,10 +214,11 @@ def switch():
213214
homeLabel.pack(side="right")
214215

215216
# Main label text:
217+
import LoginPageGUI
216218
brandLabel = Label(root, text="", font="System 30", bg="gray17", fg="green")
217219
brandLabel.place(x=100, y=250)
218220
b1=Button(root, text=' New User', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=signup, compound = LEFT, anchor="nw")
219-
b2=Button(root, text=' Login', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound = LEFT, anchor="nw")
221+
b2=Button(root, text=' Login', command=LoginPageGUI.main, bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound = LEFT, anchor="nw")
220222
b3=Button(root, text=' Login Super User', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound = LEFT, anchor="nw")
221223
b4=Button(root, text=' Delete account', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=delete, compound = LEFT, anchor="nw")
222224
b5=Button(root, text=' New Super User', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=signup, compound = LEFT, anchor="nw")
@@ -240,9 +242,9 @@ def switch():
240242
# set y-coordinate of Navbar widgets:
241243
y = 180
242244
# option in the navbar:
243-
options = ["Profile", "Settings", "Help", "About", "Feedback"]
245+
options = ["Login", "Login Super User", "New User", "New Super User", "Find Friend By Id", "Delete account"]
244246
# Navbar Option Buttons:
245-
for i in range(5):
247+
for i in range(6):
246248
Button(navRoot, text=options[i], font="BahnschriftLight 15", bg="gray17", fg=color["orange"], activebackground="gray17", activeforeground="green", bd=0).place(x=25, y=y)
247249
y += 40
248250

0 commit comments

Comments
 (0)