Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pythonclient
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charley.punshon
pythonclient
Commits
2c50ecb5
Commit
2c50ecb5
authored
Apr 27, 2021
by
charley.punshon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update main.py
parent
8405207a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
16 deletions
+23
-16
main.py
main.py
+23
-16
No files found.
main.py
View file @
2c50ecb5
...
...
@@ -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
,
2
30
,
fill
=
"black"
,
font
=
"Arial 10 bold"
,
text
=
"Login unsuccessful try again"
)
canvastitle
.
create_text
(
500
,
2
55
,
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
)
...
...
@@ -94,7 +97,7 @@ def getDogs():
row
+=
150
canvasmain
.
update_idletasks
()
canvasmain
.
configure
(
scrollregion
=
canvasmain
.
bbox
(
'all'
),
yscrollcommand
=
scrollbar
.
set
)
yscrollcommand
=
scrollbar
.
set
)
canvasmain
.
pack
(
fill
=
'both'
,
expand
=
True
,
side
=
'left'
)
scrollbar
.
pack
(
fill
=
'y'
,
side
=
'right'
)
else
:
...
...
@@ -137,7 +140,7 @@ def addDogCanvasUpdate():
def
addDog
():
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"
,
text
=
"correct types"
)
text
=
"correct types"
)
adddog
=
t
.
request
(
'POST'
,
'http://cs2s.yorkdc.net:5002/senddogs'
,
fields
=
{
'dogbreed'
:
entry1
.
get
(),
'exercise'
:
entry2
.
get
(),
'hours'
:
entry3
.
get
(),
'years'
:
entry4
.
get
(),
'growth'
:
entry5
.
get
(),
'image'
:
entry6
.
get
()})
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment