Skip to content

Commit 1933148

Browse files
committed
Public Groups Now Live a bug Remaining
1 parent 6fe0992 commit 1933148

File tree

9 files changed

+311
-44
lines changed

9 files changed

+311
-44
lines changed

GlobalChatGUI.py

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
from tkinter import *
22
from KThread import *
33
import pymongo
4-
myclient = pymongo.MongoClient(
5-
"mongodb+srv://CodingBlood:[email protected]/myFirstDatabase?retryWrites=true&w=majority")
4+
myclient = pymongo.MongoClient("mongodb+srv://CodingBlood:[email protected]/myFirstDatabase?retryWrites=true&w=majority")
65
mydb = myclient["Chatbox"]
76
mycol = mydb["UserDetails"]
87
def main(username):
98
def some():
109
x = message.get()
10+
message.set("")
1111
tasks(x)
1212
def tasks(x):
1313
def task1():
1414
mycol = mydb["GlobalChat"]
1515
for change in mycol.watch([{'$match': {'operationType': {'$in': ['insert']}}}]):
16+
# print(change)
1617
t.insert(END, change["fullDocument"]["UName"] + " : " + change["fullDocument"]["Message"] + "\n")
18+
# print("ended")
19+
break
1720
return 0
1821
def task2():
1922
GChat = mydb["GlobalChat"]
2023
mydict = {"UName": str(username), "Message": x}
2124
GChat.insert_one(mydict)
2225
return 0
2326
t1 = KThread(target=task1)
24-
t1.setDaemon(True)
27+
# t1.setDaemon(True)
2528
t1.start()
2629
task2()
2730
root1 = Toplevel()
2831
root1.geometry("1300x700")
2932
color = {"nero": "#252726", "orange": "#FF8700", "darkorange": "#FE6101"}
3033
root1.title("Chat Box")
3134
photo1 = PhotoImage(file=r"heytest.png")
32-
33-
hi=0
34-
35+
hi = 0
3536
h = Scrollbar(root1, orient='horizontal')
3637
h.pack(side=BOTTOM, fill=X)
3738
v = Scrollbar(root1)
3839
v.pack(side=RIGHT, fill=Y)
39-
t = Text(root1, width=15, height=37, wrap=NONE,xscrollcommand=h.set,yscrollcommand=v.set)
40+
t = Text(root1, width=15, height=37, wrap=NONE,xscrollcommand=h.set, yscrollcommand=v.set)
4041
t.bind("<Key>", lambda e: "break")
4142
mydb = myclient["Chatbox"]
4243
GChat = mydb["GlobalChat"]
@@ -45,41 +46,12 @@ def task2():
4546
t.pack(side=TOP, fill=X)
4647
h.config(command=t.xview)
4748
v.config(command=t.yview)
48-
49-
5049
canvas1 = Canvas(root1, width=400, height=400)
5150
canvas1.pack(fill="both", expand=True)
5251
canvas1.create_image(0, 0, image=photo1, anchor="nw")
5352
message = StringVar()
54-
b1 = Button(root1, text='SEND IT NOW --->>>',command=some, bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 10), width=15, height=3)
53+
b1 = Button(root1, text='SEND IT NOW --->>>',command=some, bg=color["nero"], fg=color["orange"], font=('Malgun Gothic Semilight', 10), width=20, height=3)
5554
l1 = Entry(root1, font=('Malgun Gothic Semilight', 25), bd=5, textvariable=message)
56-
canvas1.create_window(1110, 5, anchor="nw", window=b1)
55+
canvas1.create_window(1125, 5, anchor="nw", window=b1)
5756
canvas1.create_window(5, 5, anchor="nw", window=l1, width=1100,height=60)
58-
root1.mainloop()
59-
60-
61-
62-
63-
64-
65-
66-
67-
68-
69-
# def main(username):
70-
# print(
71-
# '''
72-
# =============================================================================================================================
73-
# | GGGGGGGGGGGGG CCCCCCCCCCCCCC |
74-
# | GGGGGGGGGGGGG CCCCCCCCCCCCCC |
75-
# | GGG CCC |
76-
# | GGG CCC |
77-
# | GGG GGGGG LL OOOOOOO BBBBBB AAAAAAAA LL CCC HH HH AAAAAAA TTTTTTTT |
78-
# | GGG GGGGG LL O O B B A A LL CCC HH HH AA AA TT |
79-
# | GGG GG LL O O BBBBBB AAAAAAAA LL CCC HHHHHHHH AAAAAAA TT |
80-
# | GGGGGGGGGGGGG LL O O B B A A LL CCCCCCCCCCCCCC HH HH AA AA TT |
81-
# | GGGGGGGGGGGGG LLLLLLLL OOOOOOO BBBBBB A A LLLLLLLL CCCCCCCCCCCCCC HH HH AA AA TT |
82-
# =============================================================================================================================
83-
# ''')
84-
# x = ""
85-
57+
root1.mainloop()

LoginPageGUI.py

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,76 @@ def some():
2222
def Gchat():
2323
import GlobalChatGUI
2424
GlobalChatGUI.main(str(name))
25+
def PuGrp():
26+
sb1.destroy()
27+
sl1.destroy()
28+
sl2.destroy()
29+
sl3.destroy()
30+
sl4.destroy()
31+
def PuGrpChat():
32+
import PublicChatGUI
33+
PublicChatGUI.main(Gname, name)
34+
#===========================================================================================================================
35+
#===========================================================================================================================
36+
#===========================================================================================================================
37+
#================NOT WORKING================================================================================================
38+
# def JoinGrp():
39+
#
40+
join = Button(root1, text='+', bg=color["nero"], fg=color["orange"],
41+
font=('Malgun Gothic Semilight', 15), width=2, bd=5, height=1, command=PuGrpChat)
42+
canvas1.create_window(65, 190, anchor="nw", window=join)
43+
#===========================================================================================================================
44+
#===========================================================================================================================
45+
#===========================================================================================================================
46+
#===========================================================================================================================
47+
pug_details = mydb["PublicChatGroups"]
48+
b=245
49+
turn=0
50+
for iterate in pug_details.find():
51+
for member in iterate["Members"]['username']:
52+
if member['username'] == name:
53+
Gname = iterate["GName"]
54+
pgrp = Button(root1, text=iterate["GName"], bg=color["nero"], fg=color["orange"],
55+
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5,image=login,
56+
compound=LEFT, anchor="nw", command=PuGrpChat)
57+
if turn >= 3:
58+
m = 700
59+
else:
60+
m = 100
61+
canvas1.create_window(m, b, anchor="nw", window=pgrp)
62+
b += 120
63+
turn += 1
64+
65+
66+
67+
def PrGrp():
68+
import GlobalChatGUI
69+
GlobalChatGUI.main(str(name))
70+
def NPuGrp():
71+
import GlobalChatGUI
72+
GlobalChatGUI.main(str(name))
73+
def NPriGrp():
74+
import GlobalChatGUI
75+
GlobalChatGUI.main(str(name))
2576
sb1 = Button(root1, text=' Global Chat', bg=color["nero"], fg=color["orange"],
2677
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
2778
compound=LEFT,anchor="nw", command=Gchat)
28-
# canvas1.create_text(100, 245, "Username", width=50, height=1, fg=color["orange"])
2979
sl1 = Button(root1, text=' Public Chat Groups', bg=color["nero"], fg=color["orange"],
3080
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
3181
compound=LEFT,
32-
anchor="nw", command=some)
82+
anchor="nw", command=PuGrp)
3383
sl2 = Button(root1, text=' Private Chat Groups', bg=color["nero"], fg=color["orange"],
3484
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
3585
compound=LEFT,
36-
anchor="nw", command=some)
86+
anchor="nw", command=PrGrp)
3787
sl3 = Button(root1, text=' New Public Group', bg=color["nero"], fg=color["orange"],
3888
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
3989
compound=LEFT,
40-
anchor="nw", command=some)
90+
anchor="nw", command=NPuGrp)
4191
sl4 = Button(root1, text=' New Private Group', bg=color["nero"], fg=color["orange"],
4292
font=('Malgun Gothic Semilight', 25, "bold"), width=500, height=100, bd=5, image=login,
4393
compound=LEFT,
44-
anchor="nw", command=some)
94+
anchor="nw", command=NPriGrp)
4595
canvas1.create_window(400, 495, anchor="nw", window=sb1)
4696
canvas1.create_window(700, 245, anchor="nw", window=sl1)
4797
canvas1.create_window(700, 370, anchor="nw", window=sl2)

PrivateChatGUI.py

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

Project Report/GUI Looks.pdf

837 KB
Binary file not shown.

Project Report/HOME PAGE.docx

4.02 MB
Binary file not shown.

0 commit comments

Comments
 (0)