Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
meal-ordering-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Taher Ahmed Muhammad Taher Ahmed
meal-ordering-app
Commits
09cf1659
Commit
09cf1659
authored
8 years ago
by
Taher Ahmed Muhammad Taher Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
In-class Kivy activity
parent
1f0ddda5
Branches
master
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+31
-0
31 additions, 0 deletions
main.py
order.kv
+77
-1
77 additions, 1 deletion
order.kv
with
108 additions
and
1 deletion
main.py
+
31
−
0
View file @
09cf1659
from
kivy.app
import
App
from
kivy.modules
import
inspector
# For inspection.
from
kivy.core.window
import
Window
# For inspection.
from
kivy.uix.slider
import
Slider
from
kivy.properties
import
BooleanProperty
from
kivy.properties
import
NumericProperty
from
kivy.uix.slider
import
Slider
__app_package__
=
'
edu.unl.cse.soft161.order
'
__app__
=
'
Order Meal
'
...
...
@@ -9,10 +14,36 @@ __flags__ = ['--bootstrap=sdl2', '--requirements=python2,kivy', '--orientation=l
class
OrderApp
(
App
):
cheese_cost
=
NumericProperty
(
0.0
)
vegan_cost
=
NumericProperty
(
0.0
)
chicken_cost
=
NumericProperty
(
0.0
)
extra_charges
=
NumericProperty
(
0.0
)
def
build
(
self
):
inspector
.
create_inspector
(
Window
,
self
)
# For inspection (press control-e to toggle).
def
active_cheese
(
self
):
if
self
.
root
.
ids
.
cheese
.
active
:
self
.
cheese_cost
+=
7
else
:
self
.
cheese_cost
=
0
def
active_chicken
(
self
):
if
self
.
root
.
ids
.
chicken
.
active
:
self
.
chicken_cost
+=
11
else
:
self
.
chicken_cost
=
0
def
active_vegan
(
self
):
if
self
.
root
.
ids
.
vegan
.
active
:
self
.
vegan_cost
+=
9.5
else
:
self
.
vegan_cost
=
0
if
__name__
==
'
__main__
'
:
app
=
OrderApp
()
app
.
run
()
This diff is collapsed.
Click to expand it.
order.kv
+
77
−
1
View file @
09cf1659
BoxLayout:
orientation: 'vertical'
color: (0, 0, 0)
Label:
text: '[Your meal-ordering GUI here]'
text: 'Pizza Restaurant'
font_size: '48sp'
BoxLayout:
orientation: 'horizontal'
Widget:
CheckBox:
id: cheese
active: False
size_hint: (None, None)
size: (sp(32), cheese_pizza.height)
on_active: app.active_cheese()
Label:
id: cheese_pizza
text: 'Cheese Pizza'
size_hint: (None, 1)
size: self.texture_size
Widget:
BoxLayout:
orientation: 'horizontal'
Widget:
CheckBox:
id: chicken
active: False
size_hint: (None, None)
size: (sp(32), chicken_pizza.height)
on_active: app.active_chicken()
Label:
id: chicken_pizza
text: 'Chicken Pizza'
size_hint: (None, 1)
size: self.texture_size
Widget:
BoxLayout:
orientation: 'horizontal'
Widget:
CheckBox:
id: vegan
active: False
size_hint: (None, None)
size: (sp(32), vegan_pizza.height)
on_active: app.active_vegan()
Label:
id: vegan_pizza
text: 'Vegan Pizza'
size_hint: (None, 1)
size: self.texture_size
Widget:
BoxLayout:
orientation: 'horizontal'
Label:
text: 'Extra pizza sauces'
font: '32sp'
Slider:
id: slider
max: 100
min: 0
value_track: True
value_track_color: (1, 1, 1, 1)
Label:
text: 'extra sausces percent ' + (str(int(slider.value)))
BoxLayout:
orientation: 'horizontal'
Label:
text: 'Pizza Cost $' + str(app.cheese_cost + app.chicken_cost + app.vegan_cost)
font: '32sp'
Label:
text: 'Extra Sauces Cost $' + '2' if slider.value > 20 else 'Extra Sauces Cost $' + '0'
font: '32sp'
BoxLayout:
orientation: 'horizontal'
Label:
text: 'Total Cost: $' + str(app.cheese_cost + app.chicken_cost + app.vegan_cost + 2) if slider.value > 20 else 'Total Cost: $' + str(app.cheese_cost + app.chicken_cost + app.vegan_cost)
font: '32sp'
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