Skip to content
Snippets Groups Projects
Commit d68496b0 authored by emahmoud3's avatar emahmoud3
Browse files

connected the displayed price to the slider.

parent 7cd4824c
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
class OrderApp(App): class OrderApp(App):
total = NumericProperty(0) # in cents
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).
def amount_changed(self):
self.total= round(self.root.ids.food.value*100)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -17,7 +17,12 @@ BoxLayout: ...@@ -17,7 +17,12 @@ BoxLayout:
size: self.texture_size size: self.texture_size
padding: (sp(12), 0) padding: (sp(12), 0)
Slider: Slider:
id: food
range: (0, 100) range: (0, 100)
on_value: app.amount_changed()
Label: Label:
text: f'Your total is $0.00' text: f' your total is ${app.total /100:.2f}.'
font_size: sp(24) font_size: sp(24)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment