Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. from kivy.app import App
  2. from kivy.uix.widget import Widget
  3. from kivy.uix.button import Button
  4. from kivy.uix.floatlayout import FloatLayout
  5. from kivy.uix.boxlayout import BoxLayout
  6.  
  7. class MenuScreen(BoxLayout):
  8.  
  9. def __init__(self,**kwargs):
  10. super(MenuScreen,self).__init__(**kwargs)
  11. self.add_widget(Button(
  12. text="Button1"))
  13. self.add_widget(Button(
  14. text="Button2"))
  15. self.add_widget(Button(
  16. text="Button3"))
  17. self.add_widget(Button(
  18. text="Button4"))
  19. self.add_widget(Button(
  20. text="Button5"))
  21.  
  22. class RootWidget(FloatLayout):
  23. def __init__(self,**kwargs):
  24. super(RootWidget,self).__init__(**kwargs)
  25. self.show_menu()
  26. def show_menu(self):
  27. self.add_widget(MenuScreen(
  28. size_hint=(0.5,0.8),
  29. pos_hint={'center_x':0.5,'center_y':0.5},
  30. orientation="vertical"))
  31. self.menuscreen=self.children[0]
  32.  
  33. def on_touch_down(self,touch):
  34. if self.menuscreen.collide_point(touch.x,touch.y)!=True:
  35. self.remove_widget(self.menuscreen)
  36.  
  37. class MyApp(App):
  38. def build(self):
  39. app=RootWidget()
  40. return app
  41.  
  42. if __name__=="__main__":
  43. MyApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement