Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Assessment 3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Toni (Bitna) Kim
Assessment 3
Commits
8120ad8e
Commit
8120ad8e
authored
3 months ago
by
Toni (Bitna) Kim
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
2f7e187d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dietGUI.py
+125
-0
125 additions, 0 deletions
dietGUI.py
with
125 additions
and
0 deletions
dietGUI.py
0 → 100644
+
125
−
0
View file @
8120ad8e
from
tkinter
import
*
from
tkinter
import
ttk
root
=
Tk
()
# create a GUI assign to 'root' (window)
root
.
title
(
'
Diet Information
'
)
s
=
ttk
.
Style
()
s
.
theme_use
(
'
clam
'
)
s
.
configure
(
'
.
'
,
font
=
(
'
Arial
'
,
10
))
diet
=
{
'
Normal
'
:
{
'
Protein
'
:
32.50
,
'
carbohydrates
'
:
60.00
,
'
fat
'
:
40.86
},
'
Oncology
'
:
{
'
Protein
'
:
35
,
'
carbohydrates
'
:
52.00
,
'
fat
'
:
37.63
},
'
Cardiology
'
:
{
'
Protein
'
:
32.50
,
'
carbohydrates
'
:
30.00
,
'
fat
'
:
26.88
},
'
Diabetes
'
:
{
'
Protein
'
:
20.00
,
'
carbohydrates
'
:
27.50
,
'
fat
'
:
27.95
},
'
Kidney
'
:
{
'
Protein
'
:
15.00
,
'
carbohydrates
'
:
55.00
,
'
fat
'
:
23.65
}
}
def
onClick
(
a
):
subtitle
.
config
(
text
=
f
"
{
a
}
diet
"
)
for
diet_name
,
nutrients
in
diet
.
items
():
if
diet_name
==
a
:
ttk
.
Label
(
contentFrame2
,
text
=
'
{:.2f}
'
.
format
(
nutrients
[
'
Protein
'
])).
grid
(
column
=
3
,
row
=
2
,
sticky
=
(
N
,
W
,
E
,
S
))
ttk
.
Label
(
contentFrame2
,
text
=
'
{:.2f}
'
.
format
(
nutrients
[
'
carbohydrates
'
])).
grid
(
column
=
3
,
row
=
3
,
sticky
=
(
N
,
W
,
E
,
S
))
ttk
.
Label
(
contentFrame2
,
text
=
nutrients
[
'
fat
'
]).
grid
(
column
=
3
,
row
=
4
,
sticky
=
(
N
,
W
,
E
,
S
))
kj
=
4
*
(
nutrients
[
'
Protein
'
])
+
4
*
(
nutrients
[
'
Protein
'
])
+
9.3
*
(
nutrients
[
'
fat
'
])
kj
=
round
(
kj
,
2
)
ttk
.
Label
(
contentFrame2
,
text
=
kj
).
grid
(
column
=
3
,
row
=
5
,
sticky
=
(
N
,
W
,
E
,
S
))
else
:
pass
root
.
minsize
(
600
,
600
)
#root frame - Main Square
root
.
columnconfigure
(
0
,
weight
=
1
)
root
.
columnconfigure
(
1
,
weight
=
3
)
root
.
columnconfigure
(
2
,
weight
=
1
)
root
.
rowconfigure
(
0
,
weight
=
1
)
root
.
rowconfigure
(
1
,
weight
=
3
)
root
.
rowconfigure
(
3
,
weight
=
1
)
#ROOT FRAME:
frame
=
ttk
.
Frame
(
root
,
padding
=
'
12 12 12 12
'
,
relief
=
'
raised
'
)
#first frame around nutrient figures
frame
.
grid
(
column
=
1
,
row
=
1
,
sticky
=
(
N
,
W
,
E
,
S
))
#the frame widget goes inside this cell.
frame
.
columnconfigure
(
0
,
weight
=
3
)
frame
.
rowconfigure
(
1
,
weight
=
1
)
# frame1
frame
.
rowconfigure
(
2
,
weight
=
1
)
# contentFrame2
frame
.
rowconfigure
(
3
,
weight
=
1
)
# contentFrame3
#TITLE FRAMES:
frame1
=
ttk
.
Frame
(
frame
,
padding
=
'
12 12 12 12
'
,
relief
=
'
solid
'
)
frame1
.
grid
(
column
=
0
,
row
=
1
,
sticky
=
(
N
,
W
,
E
,
S
))
title
=
ttk
.
Label
(
frame1
,
text
=
'
DIET NUTRITIONAL INFORMATION
'
,
font
=
(
'
Arial
'
,
16
,
'
bold
'
))
title
.
grid
(
column
=
0
,
row
=
1
,
sticky
=
(
N
,
W
,
E
,
S
))
subtitle
=
ttk
.
Label
(
frame1
,
text
=
'
Choose a Diet:
'
,
font
=
(
'
Arial
'
,
12
,
'
bold
'
))
subtitle
.
grid
(
column
=
0
,
row
=
2
,
sticky
=
(
N
,
W
,
E
,
S
))
frame1
.
rowconfigure
(
1
,
weight
=
1
)
frame1
.
rowconfigure
(
2
,
weight
=
1
)
frame1
.
columnconfigure
(
0
,
weight
=
2
)
#contentFrame2: 2ND SQUARE - 'THE NUTRITIONAL REQUIREMENTS'
# c1 row 2
contentFrame2
=
ttk
.
Frame
(
frame
,
padding
=
'
3 12 12 12
'
)
contentFrame2
.
grid
(
column
=
0
,
row
=
2
,
sticky
=
(
N
,
W
,
E
,
S
))
contentFrame2
.
configure
(
relief
=
'
solid
'
,
borderwidth
=
10
)
# contentFrame2.rowconfigure()
nutrition_label
=
ttk
.
Label
(
contentFrame2
,
text
=
'
The nutritional requirements:
'
,
font
=
(
'
Arial
'
,
10
,
'
bold
'
))
nutrition_label
.
grid
(
column
=
1
,
row
=
1
,
sticky
=
EW
)
nutrition_label
=
ttk
.
Label
(
contentFrame2
,
text
=
'
Protein (g):
'
)
nutrition_label
.
grid
(
column
=
1
,
row
=
2
,
sticky
=
EW
)
nutrition_label
=
ttk
.
Label
(
contentFrame2
,
text
=
'
Carbohydrates (g):
'
)
nutrition_label
.
grid
(
column
=
1
,
row
=
3
,
sticky
=
EW
)
nutrition_label
=
ttk
.
Label
(
contentFrame2
,
text
=
'
Fat (g):
'
)
nutrition_label
.
grid
(
column
=
1
,
row
=
4
,
sticky
=
EW
)
nutrition_label
=
ttk
.
Label
(
contentFrame2
,
text
=
'
Kilojoules (g):
'
)
nutrition_label
.
grid
(
column
=
1
,
row
=
5
,
sticky
=
EW
)
contentFrame2
.
rowconfigure
(
1
,
weight
=
2
)
contentFrame2
.
rowconfigure
(
2
,
weight
=
2
)
contentFrame2
.
rowconfigure
(
3
,
weight
=
2
)
contentFrame2
.
rowconfigure
(
4
,
weight
=
2
)
contentFrame2
.
rowconfigure
(
5
,
weight
=
2
)
contentFrame2
.
columnconfigure
(
1
,
weight
=
1
)
contentFrame2
.
columnconfigure
(
2
,
weight
=
1
)
contentFrame2
.
columnconfigure
(
3
,
weight
=
1
)
#"SELECT A DIET below Frame 3"
contentFrame3
=
ttk
.
Frame
(
frame
,
padding
=
'
12 12 12 12
'
,
relief
=
'
solid
'
)
contentFrame3
.
grid
(
column
=
0
,
row
=
3
,
sticky
=
(
N
,
W
,
E
,
S
))
contentFrame3
.
rowconfigure
(
0
,
weight
=
1
)
contentFrame3
.
columnconfigure
(
0
,
weight
=
1
)
select_label
=
ttk
.
Label
(
contentFrame3
,
text
=
'
Click a diet below to display nutritional requirements:
'
,
font
=
(
'
Arial
'
,
10
,
'
bold
'
))
select_label
.
grid
(
column
=
0
,
row
=
0
,
sticky
=
(
N
,
W
,
E
,
S
))
# Center in frame
#contentFrame4 BUTTONs:
# Select button
contentFrame4
=
ttk
.
Frame
(
frame
,
padding
=
'
12 12 12 12
'
)
contentFrame4
.
grid
(
column
=
0
,
row
=
4
,
sticky
=
(
N
,
W
,
E
,
S
))
contentFrame4
.
configure
(
relief
=
'
solid
'
,
borderwidth
=
10
)
contentFrame4
.
columnconfigure
(
2
,
weight
=
2
)
contentFrame4
.
columnconfigure
(
3
,
weight
=
2
)
contentFrame4
.
columnconfigure
(
4
,
weight
=
2
)
contentFrame4
.
columnconfigure
(
5
,
weight
=
2
)
contentFrame4
.
columnconfigure
(
6
,
weight
=
2
)
#*****
#buttons:
button1
=
ttk
.
Button
(
contentFrame4
,
text
=
'
Normal
'
,
command
=
lambda
:
onClick
(
'
Normal
'
))
button1
.
grid
(
column
=
2
,
row
=
8
,
sticky
=
EW
)
button2
=
ttk
.
Button
(
contentFrame4
,
text
=
'
Oncology
'
,
command
=
lambda
:
onClick
(
'
Oncology
'
))
button2
.
grid
(
column
=
3
,
row
=
8
,
sticky
=
EW
)
button3
=
ttk
.
Button
(
contentFrame4
,
text
=
'
Cardiology
'
,
command
=
lambda
:
onClick
(
'
Cardiology
'
))
button3
.
grid
(
column
=
4
,
row
=
8
,
sticky
=
EW
)
button4
=
ttk
.
Button
(
contentFrame4
,
text
=
'
Diabetes
'
,
command
=
lambda
:
onClick
(
'
Diabetes
'
))
button4
.
grid
(
column
=
5
,
row
=
8
,
sticky
=
EW
)
button5
=
ttk
.
Button
(
contentFrame4
,
text
=
'
Kidney
'
,
command
=
lambda
:
onClick
(
'
Kidney
'
))
button5
.
grid
(
column
=
6
,
row
=
8
,
sticky
=
EW
)
for
child
in
frame
.
winfo_children
():
child
.
grid_configure
(
padx
=
5
,
pady
=
5
)
root
.
bind
(
'
<Return>
'
,
onClick
)
root
.
mainloop
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment