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

Update main.py

parent 8405207a
...@@ -9,12 +9,11 @@ width = window.winfo_screenwidth() ...@@ -9,12 +9,11 @@ width = window.winfo_screenwidth()
height = window.winfo_screenheight() height = window.winfo_screenheight()
canvasmain = Canvas(window, width=f'{width / 2}', height=f'{height * 4}', bg='#cae8dc') canvasmain = Canvas(window, width=f'{width / 2}', height=f'{height * 4}', bg='#cae8dc')
scrollbar = Scrollbar(window, orient="vertical", command=canvasmain.yview) scrollbar = Scrollbar(window, orient="vertical", command=canvasmain.yview)
authenticated = FALSE
def login(): def login():
loginr = t.request('POST', 'http://cs2s.yorkdc.net:5002/loggedin', loginr = t.request('POST', 'http://cs2s.yorkdc.net:5002/loggedin',
fields={'username': username.get(), 'password': password.get()}) fields={'username': username.get(), 'password': password.get()})
print(loginr.status)
if loginr.status == 200: if loginr.status == 200:
canvastitle.delete("all") canvastitle.delete("all")
canvastitle.create_text(500, 75, fill="black", font="Arial 40 bold", text="Dog Breed For You") canvastitle.create_text(500, 75, fill="black", font="Arial 40 bold", text="Dog Breed For You")
...@@ -26,22 +25,27 @@ def login(): ...@@ -26,22 +25,27 @@ def login():
canvastitle.create_window(450, 180, anchor=NW, window=homeBtn) canvastitle.create_window(450, 180, anchor=NW, window=homeBtn)
menu() menu()
else: 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(): def logout():
window.destroy()
def guestclient():
canvastitle.delete("all") 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") canvasmain.delete("all")
canvastitle.create_text(500, 75, fill="black", font="Arial 40 bold", text="Login") canvasmain.create_text(1000, 75, fill="black", font="Arial 40 bold", text="Select an option")
canvastitle.create_text(400, 130, fill="black", font="Arial 15 bold", text="Username: ") # Dog Breed Info Button
username = Entry(window) dogBreedInfoBtn = Button(window, text="Get Dog Breed Information", width=30, command=getDogs)
canvastitle.create_window(550, 130, window=username) dogBreedInfoBtn.pack(pady=20)
canvastitle.create_text(400, 170, fill="black", font="Arial 15 bold", text="Password: ") canvasmain.create_window(900, 150, anchor=NW, window=dogBreedInfoBtn)
password = Entry(window) canvasmain.pack(fill='both', pady=20)
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)
def menu(): def menu():
...@@ -70,7 +74,6 @@ def getDogs(): ...@@ -70,7 +74,6 @@ def getDogs():
t = urllib3.PoolManager() t = urllib3.PoolManager()
response = t.request('GET', "http://cs2s.yorkdc.net:5002/dogs") response = t.request('GET', "http://cs2s.yorkdc.net:5002/dogs")
if response.status == 200: if response.status == 200:
scrollbar.destroy()
canvasmain.delete("all") canvasmain.delete("all")
canvasmain.create_text(900, 75, fill="black", font="Arial 40 bold", text="Dog Breed Information") canvasmain.create_text(900, 75, fill="black", font="Arial 40 bold", text="Dog Breed Information")
scrollbar = Scrollbar(window, orient="vertical", command=canvasmain.yview) scrollbar = Scrollbar(window, orient="vertical", command=canvasmain.yview)
...@@ -94,7 +97,7 @@ def getDogs(): ...@@ -94,7 +97,7 @@ def getDogs():
row += 150 row += 150
canvasmain.update_idletasks() canvasmain.update_idletasks()
canvasmain.configure(scrollregion=canvasmain.bbox('all'), canvasmain.configure(scrollregion=canvasmain.bbox('all'),
yscrollcommand=scrollbar.set) yscrollcommand=scrollbar.set)
canvasmain.pack(fill='both', expand=True, side='left') canvasmain.pack(fill='both', expand=True, side='left')
scrollbar.pack(fill='y', side='right') scrollbar.pack(fill='y', side='right')
else: else:
...@@ -137,7 +140,7 @@ def addDogCanvasUpdate(): ...@@ -137,7 +140,7 @@ def addDogCanvasUpdate():
def addDog(): def addDog():
if int(entry2.get()) and int(entry3.get()) and int(entry4.get()) and int(entry5.get()): if int(entry2.get()) and int(entry3.get()) and int(entry4.get()) and int(entry5.get()):
canvastitle.create_text(1000, 230, fill="black", font="Arial 10 bold", canvastitle.create_text(1000, 230, fill="black", font="Arial 10 bold",
text="correct types") text="correct types")
adddog = t.request('POST', 'http://cs2s.yorkdc.net:5002/senddogs', adddog = t.request('POST', 'http://cs2s.yorkdc.net:5002/senddogs',
fields={'dogbreed': entry1.get(), 'exercise': entry2.get(), 'hours': entry3.get(), fields={'dogbreed': entry1.get(), 'exercise': entry2.get(), 'hours': entry3.get(),
'years': entry4.get(), 'growth': entry5.get(), 'image': entry6.get()}) 'years': entry4.get(), 'growth': entry5.get(), 'image': entry6.get()})
...@@ -230,5 +233,9 @@ canvastitle.create_window(550, 170, window=password) ...@@ -230,5 +233,9 @@ canvastitle.create_window(550, 170, window=password)
loginBtn = Button(window, text="Login", command=login) loginBtn = Button(window, text="Login", command=login)
loginBtn.pack(pady=10) loginBtn.pack(pady=10)
loginBtn_window = canvastitle.create_window(450, 190, anchor=NW, window=loginBtn) 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) canvastitle.pack(pady=20)
window.mainloop() 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