Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Taher Ahmed Muhammad Taher Ahmed
meal-ordering-app
Commits
09cf1659
Commit
09cf1659
authored
Jan 27, 2017
by
Taher Ahmed Muhammad Taher Ahmed
Browse files
In-class Kivy activity
parent
1f0ddda5
Changes
2
Hide whitespace changes
Inline
Side-by-side
main.py
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
()
order.kv
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'
Write
Preview
Supports
Markdown
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