Skip to content
Snippets Groups Projects
Commit e54b28eb authored by mgayed2's avatar mgayed2
Browse files

* a label for the whole app chosen info

parent 565284f2
No related branches found
No related tags found
No related merge requests found
from kivy.app import App from kivy.app import App
from kivy.modules import inspector # For inspection. from kivy.modules import inspector # For inspection.
from kivy.core.window import Window # For inspection. from kivy.core.window import Window # For inspection.
from kivy.properties import NumericProperty from kivy.properties import NumericProperty,BooleanProperty
from kivy.uix.textinput import TextInput from kivy.uix.textinput import TextInput
class OrderApp(App): class OrderApp(App):
no_of_meals = NumericProperty(0) no_of_meals = NumericProperty(0)
total=NumericProperty(0) total=NumericProperty(0)
amount=NumericProperty(0) amount=NumericProperty(0)
vegan=BooleanProperty(False)
def build(self): def build(self):
inspector.create_inspector(Window, self) # For inspection (press control-e to toggle). inspector.create_inspector(Window, self) # For inspection (press control-e to toggle).
...@@ -15,7 +16,8 @@ class OrderApp(App): ...@@ -15,7 +16,8 @@ class OrderApp(App):
self.no_of_meals = int(self.root.ids.number_of_meals.text) self.no_of_meals = int(self.root.ids.number_of_meals.text)
except ValueError: except ValueError:
self.no_of_meals = 0 self.no_of_meals = 0
def type_of_food(self, is_vegan):
self.vegan = is_vegan
def amount_changed(self): def amount_changed(self):
self.total=round(self.root.ids.food.value * 100) self.total=round(self.root.ids.food.value * 100)
......
...@@ -27,10 +27,12 @@ BoxLayout: ...@@ -27,10 +27,12 @@ BoxLayout:
ToggleButton: ToggleButton:
text: 'vegan' text: 'vegan'
group: 'food_type' group: 'food_type'
on_press:app.type_of_food(True)
ToggleButton: ToggleButton:
text: 'meat eater' text: 'meat eater'
group: 'food_type' group: 'food_type'
state: 'down' state: 'down'
on_press:app.type_of_food(False)
Image: Image:
source: 'index.jpeg' source: 'index.jpeg'
...@@ -38,7 +40,6 @@ BoxLayout: ...@@ -38,7 +40,6 @@ BoxLayout:
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
Label: Label:
#on_textinput: app.Amount_of_food()
text: f'How many meals? ' text: f'How many meals? '
TextInput: TextInput:
...@@ -48,5 +49,5 @@ BoxLayout: ...@@ -48,5 +49,5 @@ BoxLayout:
text:'ok' text:'ok'
on_press:app.Amount_of_food() on_press:app.Amount_of_food()
Label: Label:
text: f'Your number of meals= {app.no_of_meals:}' text: f'Your total is $ {app.total /100:.2f}\n number of meals= {app.no_of_meals:}\n vegan:{app.vegan}'
font_size: sp(12) font_size: sp(15)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment