Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.app import App
- from kivy.lang import Builder
- from kivy.uix.screenmanager import ScreenManager, Screen
- # Create both screens. Please note the root.manager.current: this is how
- # you can control the ScreenManager from kv. Each screen has by default a
- # property manager that gives you the instance of the ScreenManager used.
- Builder.load_string("""
- <MenuScreen>:
- BoxLayout:
- Button:
- text: 'Commande'
- on_press: root.manager.current = 'commande'
- Button:
- text: 'Nouveau Produit'
- on_press: root.manager.current = 'produit'
- Button:
- text: 'Statistiques'
- on_press: root.manager.current = 'stats'
- Button:
- text: 'Goto settings'
- on_press: root.manager.current = 'settings'
- Button:
- text: 'Quit'
- <ProduitScreen>:
- GridLayout:
- rows: 3
- cols: 2
- padding: 10
- spacing: 10
- Label:
- font_size: 20
- text: 'Nom du produit'
- TextInput:
- font_size: 20
- id: nom
- Label:
- font_size: 20
- text: 'Prix'
- TextInput:
- font_size: 20
- id: prix
- Button:
- text: 'Ajouter'
- on_press: self.ajouter()
- Button:
- text: 'Quitter'
- on_press: root.manager.current = 'menu'
- <CommandeScreen>:
- GridLayout:
- rows: 4
- cols: 2
- Label:
- text: 'Prix : '
- Label:
- text: '0.00 Euros'
- Button:
- text: 'Coca'
- Label:
- text: '1.80 euros'
- Button:
- text: 'Orangina'
- Label:
- text: '1.80 euros'
- Button:
- text: 'Ajouter'
- Button:
- text: 'Quitter'
- on_press: root.manager.current = 'menu'
- <StatsScreen>:
- Button:
- text: 'Quitter'
- on_press: root.manager.current = 'menu'
- <SettingsScreen>:
- BoxLayout:
- Button:
- text: 'My settings button'
- Button:
- text: 'Back to menu'
- on_press: root.manager.current = 'menu'
- """)
- # Declare both screens
- class MenuScreen(Screen):
- pass
- class ProduitScreen(Screen):
- def ajouter():
- print "%s au prix de %d a ete ajoute" % (self.nom.txt , float(self.prix.txt))
- class CommandeScreen(Screen):
- pass
- class StatsScreen(Screen):
- pass
- class SettingsScreen(Screen):
- pass
- # Create the screen manager
- sm = ScreenManager()
- sm.add_widget(MenuScreen(name='menu'))
- sm.add_widget(SettingsScreen(name='settings'))
- sm.add_widget(ProduitScreen(name='produit'))
- sm.add_widget(CommandeScreen(name='commande'))
- sm.add_widget(StatsScreen(name='stats'))
- class TestApp(App):
- def build(self):
- return sm
- if __name__ == '__main__':
- TestApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement