From e54b28eb44c6ba3ad235db141f3bb425b6ce70a8 Mon Sep 17 00:00:00 2001 From: mgayed2 <mgayed2@huskers.unl.edu> Date: Tue, 21 Jul 2020 15:20:15 -0500 Subject: [PATCH] * a label for the whole app chosen info --- main.py | 6 ++++-- order.kv | 9 +++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 6918f44..f0fd249 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,13 @@ from kivy.app import App from kivy.modules import inspector # 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 class OrderApp(App): no_of_meals = NumericProperty(0) total=NumericProperty(0) amount=NumericProperty(0) + vegan=BooleanProperty(False) def build(self): inspector.create_inspector(Window, self) # For inspection (press control-e to toggle). @@ -15,7 +16,8 @@ class OrderApp(App): self.no_of_meals = int(self.root.ids.number_of_meals.text) except ValueError: self.no_of_meals = 0 - + def type_of_food(self, is_vegan): + self.vegan = is_vegan def amount_changed(self): self.total=round(self.root.ids.food.value * 100) diff --git a/order.kv b/order.kv index 9aa6e05..20a4f60 100644 --- a/order.kv +++ b/order.kv @@ -27,10 +27,12 @@ BoxLayout: ToggleButton: text: 'vegan' group: 'food_type' + on_press:app.type_of_food(True) ToggleButton: text: 'meat eater' group: 'food_type' state: 'down' + on_press:app.type_of_food(False) Image: source: 'index.jpeg' @@ -38,7 +40,6 @@ BoxLayout: BoxLayout: orientation: 'horizontal' Label: - #on_textinput: app.Amount_of_food() text: f'How many meals? ' TextInput: @@ -47,6 +48,6 @@ BoxLayout: Button: text:'ok' on_press:app.Amount_of_food() - Label: - text: f'Your number of meals= {app.no_of_meals:}' - font_size: sp(12) + Label: + text: f'Your total is $ {app.total /100:.2f}\n number of meals= {app.no_of_meals:}\n vegan:{app.vegan}' + font_size: sp(15) -- GitLab