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 class OrderApp(App): total = NumericProperty(0) # stores price in cents burgers = NumericProperty(0) # number of burgers ordered fries = NumericProperty(0) # number of fries ordered drinks = NumericProperty(0) # number of drinks ordered def build(self): inspector.create_inspector(Window, self) # For inspection (press control-e to toggle). def update_total(self): self.total = self.burgers * 500 + self.drinks * 300 + self.fries * 200 self.total = self.total * 1.07 # Add in sales tax # Add or subtract a burger based on if the + or - button is selected def update_burgers(self): if self.root.ids.plus.state == 'down': self.burgers += 1 elif self.burgers > 0 and self.root.ids.minus.state == 'down': self.burgers -= 1 self.update_total() # Add or subtract a drink based on if the + or - button is selected def update_drinks(self): if self.root.ids.plus.state == 'down': self.drinks += 1 elif self.drinks > 0 and self.root.ids.minus.state == 'down': self.drinks -= 1 self.update_total() # Add or subtract an order of fries based on if the + or - button is selected def update_fries(self): if self.root.ids.plus.state == 'down': self.fries += 1 elif self.fries > 0 and self.root.ids.minus.state == 'down': self.fries -= 1 self.update_total() def checkout(self): # prints the total to the console print(f'The user checked out with a total of ${self.total/100:.2f}') self.burgers = 0 self.drinks = 0 self.fries = 0 self.total = 0 print('test') if __name__ == '__main__': app = OrderApp() app.run()