Commit 2c50ecb5 authored by charley.punshon's avatar charley.punshon

Update main.py

parent 8405207a
......@@ -9,12 +9,11 @@ width = window.winfo_screenwidth()
height = window.winfo_screenheight()
canvasmain = Canvas(window, width=f'{width / 2}', height=f'{height * 4}', bg='#cae8dc')
scrollbar = Scrollbar(window, orient="vertical", command=canvasmain.yview)
authenticated = FALSE
def login():
loginr = t.request('POST', 'http://cs2s.yorkdc.net:5002/loggedin',
fields={'username': username.get(), 'password': password.get()})
print(loginr.status)
if loginr.status == 200:
canvastitle.delete("all")
canvastitle.create_text(500, 75, fill="black", font="Arial 40 bold", text="Dog Breed For You")
......@@ -26,22 +25,27 @@ def login():
canvastitle.create_window(450, 180, anchor=NW, window=homeBtn)
menu()
else:
canvastitle.create_text(500, 230, fill="black", font="Arial 10 bold", text="Login unsuccessful try again")
canvastitle.create_text(500, 255, fill="black", font="Arial 10 bold", text="Login unsuccessful try again")
def logout():
window.destroy()
def guestclient():
canvastitle.delete("all")
canvastitle.create_text(500, 75, fill="black", font="Arial 40 bold", text="Dog Breed For You")
homeBtn = Button(window, text="Home", command=guestclient)
homeBtn.pack(pady=20)
canvastitle.create_window(450, 180, anchor=NW, window=homeBtn)
canvasmain.delete("all")
canvastitle.create_text(500, 75, fill="black", font="Arial 40 bold", text="Login")
canvastitle.create_text(400, 130, fill="black", font="Arial 15 bold", text="Username: ")
username = Entry(window)
canvastitle.create_window(550, 130, window=username)
canvastitle.create_text(400, 170, fill="black", font="Arial 15 bold", text="Password: ")
password = Entry(window)
canvastitle.create_window(550, 170, window=password)
loginBtn = Button(window, text="Login", command=login)
loginBtn.pack(pady=10)
canvastitle.create_window(450, 190, anchor=NW, window=loginBtn)
canvasmain.create_text(1000, 75, fill="black", font="Arial 40 bold", text="Select an option")
# Dog Breed Info Button
dogBreedInfoBtn = Button(window, text="Get Dog Breed Information", width=30, command=getDogs)
dogBreedInfoBtn.pack(pady=20)
canvasmain.create_window(900, 150, anchor=NW, window=dogBreedInfoBtn)
canvasmain.pack(fill='both', pady=20)
def menu():
......@@ -70,7 +74,6 @@ def getDogs():
t = urllib3.PoolManager()
response = t.request('GET', "http://cs2s.yorkdc.net:5002/dogs")
if response.status == 200:
scrollbar.destroy()
canvasmain.delete("all")
canvasmain.create_text(900, 75, fill="black", font="Arial 40 bold", text="Dog Breed Information")
scrollbar = Scrollbar(window, orient="vertical", command=canvasmain.yview)
......@@ -230,5 +233,9 @@ canvastitle.create_window(550, 170, window=password)
loginBtn = Button(window, text="Login", command=login)
loginBtn.pack(pady=10)
loginBtn_window = canvastitle.create_window(450, 190, anchor=NW, window=loginBtn)
canvastitle.create_window(550, 170, window=password)
guestLoginBtn = Button(window, text="Login as Guest", command=guestclient)
guestLoginBtn.pack(pady=10)
guestLoginBtn_window = canvastitle.create_window(445, 220, anchor=NW, window=guestLoginBtn)
canvastitle.pack(pady=20)
window.mainloop()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment