Skip to content

Commit 3f1ea67

Browse files
committed
Can Create New Users Now
1 parent 396f4a2 commit 3f1ea67

15 files changed

+357
-75
lines changed

ChatBoxGUI/GlobalChatGUI.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,32 @@
33
import pymongo
44
myclient = pymongo.MongoClient("mongodb+srv://CodingBlood:[email protected]/myFirstDatabase?retryWrites=true&w=majority")
55
mydb = myclient["Chatbox"]
6-
mycol = mydb["UserDetails"]
76
def main(username):
87
def some():
98
x = message.get()
109
message.set("")
1110
tasks(x)
1211
def tasks(x):
13-
def task1():
14-
mycol = mydb["GlobalChat"]
15-
for change in mycol.watch([{'$match': {'operationType': {'$in': ['insert']}}}]):
16-
# print(change)
17-
t.insert(END, change["fullDocument"]["UName"] + " : " + change["fullDocument"]["Message"] + "\n")
18-
# print("ended")
19-
break
20-
return 0
2112
def task2():
2213
GChat = mydb["GlobalChat"]
2314
mydict = {"UName": str(username), "Message": x}
2415
GChat.insert_one(mydict)
2516
return 0
26-
t1 = KThread(target=task1)
27-
# t1.setDaemon(True)
28-
t1.start()
17+
2918
task2()
19+
def task1():
20+
mydb = myclient["Chatbox"]
21+
mycol = mydb["GlobalChat"]
22+
for change in mycol.watch([{'$match': {'operationType': {'$in': ['insert']}}}]):
23+
# print(change)
24+
t.insert(END, change["fullDocument"]["UName"] + " : " + change["fullDocument"]["Message"] + "\n")
25+
# print("ended")
26+
# break
27+
return 0
28+
29+
t1 = KThread(target=task1)
30+
# t1.setDaemon(True)
31+
t1.start()
3032
root1 = Toplevel()
3133
root1.geometry("1300x700")
3234
color = {"nero": "#252726", "orange": "#FF8700", "darkorange": "#FE6101"}

ChatBoxGUI/LoginPageGUI.py

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -170,27 +170,68 @@ def submit():
170170
canvas1.create_window(100, 335, anchor="nw", window=desc_of_group1)
171171

172172
def NPriGrp():
173-
import GlobalChatGUI
174-
GlobalChatGUI.main(str(name))
175-
sb1 = Button(root1, text=' Global Chat', bg=color["nero"], fg=color["orange"],
176-
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
177-
compound=LEFT,anchor="nw", command=Gchat)
178-
sl1 = Button(root1, text=' Public Chat Groups', bg=color["nero"], fg=color["orange"],
179-
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
180-
compound=LEFT,
181-
anchor="nw", command=PuGrp)
182-
sl2 = Button(root1, text=' Private Chat Groups', bg=color["nero"], fg=color["orange"],
183-
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
184-
compound=LEFT,
185-
anchor="nw", command=PrGrp)
186-
sl3 = Button(root1, text=' New Public Group', bg=color["nero"], fg=color["orange"],
187-
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
188-
compound=LEFT,
189-
anchor="nw", command=NPuGrp)
190-
sl4 = Button(root1, text=' New Private Group', bg=color["nero"], fg=color["orange"],
191-
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
192-
compound=LEFT,
193-
anchor="nw", command=NPriGrp)
173+
Ngn = StringVar()
174+
Ngd = StringVar()
175+
NgS = StringVar()
176+
sb1.destroy()
177+
sl1.destroy()
178+
sl2.destroy()
179+
sl3.destroy()
180+
sl4.destroy()
181+
def submit():
182+
GName=Ngn.get()
183+
Desc=Ngd.get()
184+
Skey=NgS.get()
185+
myquery = {"Gname": GName, "Owner": name}
186+
mycol = mydb["PrivateChatGroups"]
187+
mydoc = mycol.find(myquery)
188+
for x in mydoc:
189+
res = not bool(x)
190+
while not res:
191+
print("Similar Group Already Exists Already Exists")
192+
NPriGrp()
193+
mydict = {"GName": GName,
194+
"Desc": Desc,
195+
"SKey": Skey,
196+
"Owner": name,
197+
"Admins": {
198+
"username": [name]
199+
},
200+
"Members": {
201+
"username": [{
202+
"username": name,
203+
}
204+
]
205+
},
206+
"Chats": [
207+
{
208+
"username": name,
209+
"Message": "Booyahh! Welcome To My Own Public Group"
210+
}
211+
]
212+
}
213+
temp = mycol.insert_one(mydict)
214+
from ChatBoxGUI import PrivateChatGUI
215+
PrivateChatGUI.main(GName, name)
216+
submit = Button(root1,command=submit , text=' CreateGroup', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound=LEFT, anchor="nw")
217+
Name_of_group = Entry(root1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5, textvariable=Ngn)
218+
Desc_of_group = Entry(root1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5, textvariable=Ngd)
219+
Skey_of_group = Entry(root1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5, textvariable=NgS, show='*')
220+
Desc_of_group1 = Label(root1, text='Description Of Group', width=18, height=1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5)
221+
Name_of_group1 = Label(root1, text='Group Name', width=18, height=1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5)
222+
Skey_of_group1 = Label(root1, text='Security Key', width=18, height=1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5)
223+
canvas1.create_window(300, 585, anchor="nw", window=submit)
224+
canvas1.create_window(700, 210, anchor="nw", window=Name_of_group)
225+
canvas1.create_window(700, 335, anchor="nw", window=Desc_of_group)
226+
canvas1.create_window(100, 210, anchor="nw", window=Name_of_group1)
227+
canvas1.create_window(700, 460, anchor="nw", window=Skey_of_group)
228+
canvas1.create_window(100, 460, anchor="nw", window=Skey_of_group1)
229+
canvas1.create_window(100, 335, anchor="nw", window=Desc_of_group1)
230+
sb1 = Button(root1, text=' Global Chat', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound=LEFT,anchor="nw", command=Gchat)
231+
sl1 = Button(root1, text=' Public Chat Groups', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound=LEFT, anchor="nw", command=PuGrp)
232+
sl2 = Button(root1, text=' Private Chat Groups', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound=LEFT, anchor="nw", command=PrGrp)
233+
sl3 = Button(root1, text=' New Public Group', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound=LEFT, anchor="nw", command=NPuGrp)
234+
sl4 = Button(root1, text=' New Private Group', bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound=LEFT, anchor="nw", command=NPriGrp)
194235
canvas1.create_window(400, 495, anchor="nw", window=sb1)
195236
canvas1.create_window(700, 245, anchor="nw", window=sl1)
196237
canvas1.create_window(700, 370, anchor="nw", window=sl2)
@@ -268,10 +309,10 @@ def switch():
268309
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login, compound=LEFT,
269310
anchor="nw", command=some)
270311
# canvas1.create_text(100, 245, "Username", width=50, height=1, fg=color["orange"])
271-
l1 = Entry(root1,font=('Malgun Gothic Semilight', 25, "bold"),bd=5, textvariable=userid)
272-
l2 = Entry(root1,font=('Malgun Gothic Semilight', 25, "bold"),bd=5, textvariable=paswrd, show='*')
273-
l3 = Label(root1, text='UserName', width=15, height=1, font=('Malgun Gothic Semilight', 25, "bold"),bd=5)
274-
l4 = Label(root1, text='Password', width=15, height=1, font=('Malgun Gothic Semilight', 25, "bold"),bd=5)
312+
l1 = Entry(root1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5, textvariable=userid)
313+
l2 = Entry(root1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5, textvariable=paswrd, show='*')
314+
l3 = Label(root1, text='UserName', width=15, height=1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5)
315+
l4 = Label(root1, text='Password', width=15, height=1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5)
275316
canvas1.create_window(300, 495, anchor="nw", window=b1)
276317
canvas1.create_window(700, 245, anchor="nw", window=l1)
277318
canvas1.create_window(700, 370, anchor="nw", window=l2)

ChatBoxGUI/PrivateChatGUI.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@ def some():
1010
message.set("")
1111
tasks(x)
1212
def tasks(x):
13-
def task1():
14-
mycol = mydb["PrivateChatGroups"]
15-
for change in mycol.watch(full_document='updateLookup'):
16-
t.insert(END, change["fullDocument"]["Chats"][-1]["username"] + " : " + change["fullDocument"]["Chats"][-1]["Message"] + "\n")
17-
break
18-
return 0
19-
20-
21-
2213

2314
def task2():
2415
mydict = {"username": str(username), "Message": x}
@@ -27,10 +18,20 @@ def task2():
2718
document['Chats'].append(mydict)
2819
PChat.update({'GName': Gname}, document)
2920
return 0
30-
t1 = KThread(target=task1)
31-
# t1.setDaemon(True)
32-
t1.start()
21+
3322
task2()
23+
24+
def task1():
25+
mycol = mydb["PrivateChatGroups"]
26+
for change in mycol.watch(full_document='updateLookup'):
27+
t.insert(END, change["fullDocument"]["Chats"][-1]["username"] + " : " + change["fullDocument"]["Chats"][-1][
28+
"Message"] + "\n")
29+
break
30+
return 0
31+
32+
t1 = KThread(target=task1)
33+
# t1.setDaemon(True)
34+
t1.start()
3435
# print(Gname)
3536
root1 = Toplevel()
3637
root1.geometry("1300x700")

ChatBoxGUI/PublicChatGUI.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,24 @@ def some():
1010
message.set("")
1111
tasks(x)
1212
def tasks(x):
13-
def task1():
14-
mycol = mydb["PublicChatGroups"]
15-
for change in mycol.watch(full_document='updateLookup'):
16-
t.insert(END, change["fullDocument"]["Chats"][-1]["username"] + " : " + change["fullDocument"]["Chats"][-1]["Message"] + "\n")
17-
break
18-
return 0
19-
20-
21-
22-
2313
def task2():
2414
mydict = {"username": str(username), "Message": x}
2515
PChat = mydb["PublicChatGroups"]
2616
document = dict(PChat.find_one({'GName': Gname}))
2717
document['Chats'].append(mydict)
2818
PChat.update({'GName': Gname}, document)
2919
return 0
30-
t1 = KThread(target=task1)
31-
# t1.setDaemon(True)
32-
t1.start()
3320
task2()
34-
# print(Gname)
21+
22+
def task1():
23+
mycol = mydb["PublicChatGroups"]
24+
for change in mycol.watch(full_document='updateLookup'):
25+
t.insert(END, change["fullDocument"]["Chats"][-1]["username"] + " : " + change["fullDocument"]["Chats"][-1][
26+
"Message"] + "\n")
27+
return 0
28+
29+
t1 = KThread(target=task1)
30+
t1.start()
3531
root1 = Toplevel()
3632
root1.geometry("1300x700")
3733
color = {"nero": "#252726", "orange": "#FF8700", "darkorange": "#FE6101"}

ChatBoxGUI/SUserSignUpGUI.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
from tkinter import *
2+
import pymongo
3+
myclient = pymongo.MongoClient("mongodb+srv://CodingBlood:[email protected]/myFirstDatabase?retryWrites=true&w=majority")
4+
mydb = myclient["Chatbox"]
5+
def main():
6+
# setting switch function:
7+
def switch():
8+
global btnState
9+
if btnState is True:
10+
# create animated Navbar closing:
11+
for x in range(301):
12+
navRoot.place(x=-x, y=0)
13+
topFrame.update()
14+
15+
# resetting widget colors:
16+
brandLabel.config(bg="gray17", fg="green")
17+
homeLabel.config(bg=color["orange"])
18+
topFrame.config(bg=color["orange"])
19+
# root.config(bg="gray17")
20+
21+
# turning button OFF:
22+
btnState = False
23+
else:
24+
# make root dim:
25+
brandLabel.config(bg=color["nero"], fg="#5F5A33")
26+
# homeLabel.config(bg=color["nero"])
27+
topFrame.config(bg=color["nero"])
28+
root.config(bg=color["nero"])
29+
30+
# created animated Navbar opening:
31+
for x in range(-300, 0):
32+
navRoot.place(x=x, y=0)
33+
topFrame.update()
34+
35+
# turing button ON:
36+
btnState = True
37+
root = Toplevel()
38+
root.geometry("1300x700")
39+
color = {"nero": "#252726", "orange": "#FF8700", "darkorange": "#FE6101"}
40+
root.title("Chat Box")
41+
# setting switch state:
42+
btnState = False
43+
# loading Navbar icon image:
44+
navIcon = PhotoImage(file=r"./ChatBoxGUI/ham.png")
45+
closeIcon = PhotoImage(file=r"./ChatBoxGUI/goback.png")
46+
login = PhotoImage(file=r"./ChatBoxGUI/login.png", height=100, width=100)
47+
photo1 = PhotoImage(file=r"./ChatBoxGUI/heytest.png")
48+
canvas1 = Canvas(root, width=400, height=400)
49+
canvas1.pack(fill="both", expand=True)
50+
canvas1.create_image(0, 0, image=photo1, anchor="nw")
51+
52+
# top Navigation bar:
53+
topFrame = Frame(root, bg=color["orange"])
54+
canvas1.create_window(0, 0, anchor="nw", window=topFrame, width="1300", height="125")
55+
# topFrame.pack(side="top", fill=X)
56+
57+
# Header label text:
58+
homeLabel = Label(topFrame, text="Chat Box", font="Bahnschrift 95", bg=color["orange"], fg="gray17", height=2,
59+
padx=20)
60+
homeLabel.pack(side="right")
61+
62+
# Main label text:
63+
64+
mycol = mydb["UserDetails"]
65+
sun = StringVar()
66+
sup = StringVar()
67+
skey = StringVar()
68+
def some():
69+
if skey.get() != "9211BadAss!)@(#*$&%^BadAss9211":
70+
some()
71+
else:
72+
mycol = mydb["SuperUserDetails"]
73+
myquery = {"UName": sun.get()}
74+
mydoc = mycol.find(myquery)
75+
for x in mydoc:
76+
res = not bool(x)
77+
while not res:
78+
root.destroy()
79+
some()
80+
mydict = {"UName": sun.get(), "UPassword": sup.get()}
81+
x = mycol.insert_one(mydict)
82+
root.destroy()
83+
brandLabel = Label(root, text="", font="System 30", bg="gray17", fg="green")
84+
brandLabel.place(x=100, y=250)
85+
submit = Button(root, command=some, text='Create 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")
86+
s_key = Entry(root, font=('Malgun Gothic Semilight', 25, "bold"), bd=5, textvariable=skey, show='*')
87+
super_user_name = Entry(root, font=('Malgun Gothic Semilight', 25, "bold"), bd=5, textvariable=sun)
88+
super_user_password = Entry(root, font=('Malgun Gothic Semilight', 25, "bold"), bd=5, textvariable=sup, show='*')
89+
s_key1 = Label(root, text='Security Key', width=18, height=1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5)
90+
super_user_name1 = Label(root, text='User Name', width=18, height=1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5)
91+
super_user_password1 = Label(root, text='Password', width=18, height=1, font=('Malgun Gothic Semilight', 25, "bold"), bd=5)
92+
canvas1.create_window(300, 585, anchor="nw", window=submit)
93+
canvas1.create_window(700, 210, anchor="nw", window=super_user_name)
94+
canvas1.create_window(700, 335, anchor="nw", window=super_user_password)
95+
canvas1.create_window(100, 210, anchor="nw", window=super_user_name1)
96+
canvas1.create_window(700, 460, anchor="nw", window=s_key)
97+
canvas1.create_window(100, 460, anchor="nw", window=s_key1)
98+
canvas1.create_window(100, 335, anchor="nw", window=super_user_password1)
99+
100+
# Navbar button:
101+
navbarBtn = Button(topFrame, image=navIcon, bg=color["orange"], activebackground=color["orange"], bd=0, padx=20,
102+
command=switch)
103+
navbarBtn.place(x=10, y=10)
104+
105+
# setting Navbar frame:
106+
navRoot = Frame(root, bg="gray17", height=1000, width=300)
107+
navRoot.place(x=-300, y=0)
108+
Label(navRoot, font="Bahnschrift 15", bg=color["orange"], fg="black", height=2, width=300, padx=20).place(x=0, y=0)
109+
110+
# set y-coordinate of Navbar widgets:
111+
y = 180
112+
# option in the navbar:
113+
options = ["Login", "Login Super User", "New User", "New Super User", "Find Friend By Id", "Delete account"]
114+
# Navbar Option Buttons:
115+
for i in range(6):
116+
Button(navRoot, text=options[i], font="BahnschriftLight 15", bg="gray17", fg=color["orange"],
117+
activebackground="gray17", activeforeground="green", bd=0).place(x=25, y=y)
118+
y += 40
119+
120+
# Navbar Close Button:
121+
closeBtn = Button(navRoot, image=closeIcon, bg=color["orange"], activebackground=color["orange"], bd=0,
122+
command=switch)
123+
closeBtn.place(x=150, y=10)
124+
125+
root.mainloop()
126+

0 commit comments

Comments
 (0)