Skip to content

Commit 2013d5c

Browse files
committed
Improved and Fiexd Bugs In GUI version
1 parent 887b75a commit 2013d5c

File tree

4 files changed

+167
-70
lines changed

4 files changed

+167
-70
lines changed

LoginPageGUI.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from tkinter import *
2+
def main():
3+
User_login = Tk()
4+
userid = StringVar()
5+
paswrd = StringVar()
6+
def some():
7+
name = userid.get()
8+
pass_wrd = paswrd.get()
9+
print("The name is : " + name)
10+
print("The password is : " + pass_wrd)
11+
userid.set("")
12+
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()
1.17 KB
Binary file not shown.
2.31 KB
Binary file not shown.

main_gui.py

Lines changed: 143 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,144 @@
1-
import tkinter.constants
2-
from tkinter import *
3-
def NUser():
4-
New_User = Tk()
5-
New_User.title("New User")
6-
some = Button(New_User, text='Go Back', command=New_User.destroy, width=50, height=2)
7-
some.pack()
8-
New_User.mainloop()
9-
def ULogin():
10-
New_User = Tk()
11-
New_User.title("Login")
12-
some = Button(New_User, text='Go Back', command=New_User.destroy, width=50, height=2)
13-
some.pack()
14-
New_User.mainloop()
15-
def SULogin():
16-
New_User = Tk()
17-
New_User.title("Super User Login")
18-
some = Button(New_User, text='Go Back', command=New_User.destroy, width=50, height=2)
19-
some.pack()
20-
New_User.mainloop()
21-
def DUser():
22-
New_User = Tk()
23-
New_User.title("Delete User")
24-
some = Button(New_User, text='Go Back', command=New_User.destroy, width=50, height=2)
25-
some.pack()
26-
New_User.mainloop()
27-
def NSUser():
28-
New_User = Tk()
29-
New_User.title("New Super User")
30-
some = Button(New_User, text='Go Back', command=New_User.destroy, width=50, height=2)
31-
some.pack()
32-
New_User.mainloop()
33-
def FFinder():
34-
New_User = Tk()
35-
New_User.title("Find My Friend")
36-
some = Button(New_User, text='Go Back', command=New_User.destroy, width=50, height=2)
37-
some.pack()
38-
New_User.mainloop()
391

40-
def main():
41-
chatbox_home = Tk()
42-
chatbox_home.title("Chat Box")
43-
w = Frame(chatbox_home)
44-
hello = Label(chatbox_home, text='Hi there Welcome to Online Chatting Room', width=50, height=2)
45-
hello.pack()
46-
some = Label(chatbox_home, text='Only benefit of this is no one knows you are here :):)', width=50, height=2)
47-
some.pack()
48-
choose = Label(chatbox_home, text='Choose Wisely:---------------', width=50, height=2)
49-
choose.pack()
50-
NUserButton = Button(chatbox_home, text='New User',fg='red', command=NUser, width=50, height=2)
51-
NUserButton.pack(side=TOP)
52-
Login = Button(chatbox_home, text='Login', fg='red', command=ULogin, width=50, height=2)
53-
Login.pack(side=TOP)
54-
User = Button(chatbox_home, text='Login Super User', fg='red', command=SULogin, width=50, height=2)
55-
User.pack(side=TOP)
56-
DelAcc = Button(chatbox_home, text='Delete account', fg='red', command=DUser, width=50, height=2)
57-
DelAcc.pack(side=TOP)
58-
SUser = Button(chatbox_home, text='New Super User', fg='red', command=NSUser, width=50, height=2)
59-
SUser.pack(side=TOP)
60-
findfriend = Button(chatbox_home, text='Find Friend By Id', fg='red', command=FFinder, width=50, height=2)
61-
findfriend.pack(side=TOP)
62-
w.pack()
63-
chatbox_home.mainloop()
64-
# main()
65-
while True:
66-
try:
67-
main()
68-
except:
69-
main()
70-
finally:
71-
main()
2+
# def ULogin():
3+
# w.pack_forget()
4+
# userid = StringVar()
5+
# paswrd = StringVar()
6+
#
7+
# def some():
8+
# name = userid.get()
9+
# pass_wrd = paswrd.get()
10+
# print("The name is : " + name)
11+
# print("The password is : " + pass_wrd)
12+
# userid.set("")
13+
# paswrd.set("")
14+
# # l.destroy()
15+
#
16+
# chatbox_home.title("Login")
17+
# Label(l, text='UserName', width=50, height=2).grid(row=0, column=0)
18+
# Label(l, text='Password', width=50, height=2).grid(row=1, column=0)
19+
# e1 = Entry(l, bd=5, textvariable=userid)
20+
# e2 = Entry(l, bd=5, textvariable=paswrd, show='*')
21+
# login = Button(l, text='Login', command=some, width=100, height=2, bd=5)
22+
# go_back = Button(l, text='Go Back', command=main, width=100, height=2, bd=5)
23+
# e1.grid(row=0, column=1, padx=100, pady=4)
24+
# e2.grid(row=1, column=1, padx=100, pady=4)
25+
# login.grid(row=2, columnspan=2, padx=100, pady=4)
26+
# go_back.grid(row=3, columnspan=2, padx=100, pady=4)
27+
# l.pack()
28+
29+
# =========================REMEMBER IMPORTANT FOR CHATS==================================================================
30+
# import tkinter as tk
31+
#
32+
# root = tk.Tk()
33+
# root.geometry('600x400+80+40')
34+
#
35+
#
36+
# class App:
37+
# def __init__(self, root):
38+
# self.entry_var = tk.StringVar()
39+
# self.entry = tk.Entry(root, textvariable=self.entry_var)
40+
# self.entry.bind('<Return>', self.show_output)
41+
# self.entry.pack()
42+
#
43+
# def show_output(self, event):
44+
# print(self.entry_var.get())
45+
#
46+
#
47+
# App(root)
48+
# tk.mainloop()\
49+
# =======================================================================================================================
50+
#=======================================================================================================================
51+
try:
52+
from tkinter import *
53+
except:
54+
from tkinter import *
55+
56+
57+
class SampleApp(Tk):
58+
def __init__(self):
59+
Tk.__init__(self)
60+
self.title("Chat Box")
61+
self.geometry("1000x800")
62+
self._frame = None
63+
self.switch_frame(StartPage)
64+
65+
def switch_frame(self, frame_class):
66+
new_frame = frame_class(self)
67+
if self._frame is not None:
68+
self._frame.destroy()
69+
self._frame = new_frame
70+
self._frame.pack()
71+
72+
73+
class StartPage(Frame):
74+
def __init__(self, master):
75+
Frame.__init__(self, master)
76+
Label(self, text="Hi there Welcome to Online Chatting Room", font=('Helvetica', 18, "bold")).pack(side="top", fill="x", pady=5)
77+
Label(self, text="Only benefit of this is no one knows you are here :):)", font=('Helvetica', 18, "bold")).pack(side="top", fill="x", pady=5)
78+
Label(self, text="Choose Wisely:---------------", font=('Helvetica', 18, "bold")).pack(side="top", fill="x", pady=5)
79+
Button(self, text='New User', fg='red', command=lambda: master.switch_frame(NUser), width=50, height=2).pack()
80+
Button(self, text='Login', fg='red', command=lambda: master.switch_frame(ULogin), width=50, height=2).pack()
81+
Button(self, text='Login Super User', fg='red', command=lambda: master.switch_frame(SULogin), width=50, height=2).pack()
82+
Button(self, text='Delete account', fg='red', command=lambda: master.switch_frame(DUser), width=50, height=2).pack()
83+
Button(self, text='New Super User', fg='red', command=lambda: master.switch_frame(NSUser), width=50, height=2).pack()
84+
Button(self, text='Find Friend By Id', fg='red', command=lambda: master.switch_frame(FFinder), width=50, height=2).pack()
85+
class FFinder(Frame):
86+
def __init__(self, master):
87+
Frame.__init__(self, master)
88+
Frame.configure(self, bg='blue')
89+
Label(self, text="Find My Friend", font=('Helvetica', 18, "bold")).pack(side="top", fill="x", pady=5)
90+
Button(self, text="Go back to start page",
91+
command=lambda: master.switch_frame(StartPage)).pack()
92+
class NSUser(Frame):
93+
def __init__(self, master):
94+
Frame.__init__(self, master)
95+
Frame.configure(self, bg='blue')
96+
Label(self, text="New Super User", font=('Helvetica', 18, "bold")).pack(side="top", fill="x", pady=5)
97+
Button(self, text="Go back to start page",
98+
command=lambda: master.switch_frame(StartPage)).pack()
99+
class DUser(Frame):
100+
def __init__(self, master):
101+
Frame.__init__(self, master)
102+
Frame.configure(self, bg='blue')
103+
Label(self, text="Delete User", font=('Helvetica', 18, "bold")).pack(side="top", fill="x", pady=5)
104+
Button(self, text="Go back to start page",
105+
command=lambda: master.switch_frame(StartPage)).pack()
106+
107+
class SULogin(Frame):
108+
def __init__(self, master):
109+
Frame.__init__(self, master)
110+
Frame.configure(self, bg='blue')
111+
Label(self, text="Super User Login", font=('Helvetica', 18, "bold")).pack(side="top", fill="x", pady=5)
112+
Button(self, text="Go back to start page",
113+
command=lambda: master.switch_frame(StartPage)).pack()
114+
class ULogin(Frame):
115+
def __init__(self, master):
116+
Frame.__init__(self, master)
117+
Frame.configure(self, bg='red')
118+
userid = StringVar()
119+
paswrd = StringVar()
120+
def some():
121+
name = userid.get()
122+
pass_wrd = paswrd.get()
123+
print("The name is : " + name)
124+
print("The password is : " + pass_wrd)
125+
userid.set("")
126+
paswrd.set("")
127+
Label(self, text="UserName", font=('Helvetica', 18, "bold")).pack()
128+
Label(self, text="Password", font=('Helvetica', 18, "bold")).pack()
129+
Entry(self, bd=5, textvariable=userid).pack()
130+
Entry(self, bd=5, textvariable=paswrd).pack()
131+
Button(self, text='Login', command=some, width=100, height=2, bd=5).pack()
132+
Button(self, text="Go back to start page", width=100, height=2, bd=5,
133+
command=lambda: master.switch_frame(StartPage)).pack()
134+
135+
class NUser(Frame):
136+
def __init__(self, master):
137+
Frame.__init__(self, master)
138+
Frame.configure(self, bg='red')
139+
Label(self, text="New User", font=('Helvetica', 18, "bold")).pack(side="top", fill="x", pady=5)
140+
Button(self, text="Go back to start page",
141+
command=lambda: master.switch_frame(StartPage)).pack()
142+
if __name__ == "__main__":
143+
app = SampleApp()
144+
app.mainloop()

0 commit comments

Comments
 (0)