Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.app import App
- from kivy.uix.widget import Widget
- from kivy.uix.button import Button
- from kivy.uix.floatlayout import FloatLayout
- from kivy.uix.boxlayout import BoxLayout
- class MenuScreen(BoxLayout):
- def __init__(self,**kwargs):
- super(MenuScreen,self).__init__(**kwargs)
- self.add_widget(Button(
- text="Button1"))
- self.add_widget(Button(
- text="Button2"))
- self.add_widget(Button(
- text="Button3"))
- self.add_widget(Button(
- text="Button4"))
- self.add_widget(Button(
- text="Button5"))
- class RootWidget(FloatLayout):
- def __init__(self,**kwargs):
- super(RootWidget,self).__init__(**kwargs)
- self.show_menu()
- def show_menu(self):
- self.add_widget(MenuScreen(
- size_hint=(0.5,0.8),
- pos_hint={'center_x':0.5,'center_y':0.5},
- orientation="vertical"))
- self.menuscreen=self.children[0]
- def on_touch_down(self,touch):
- if self.menuscreen.collide_point(touch.x,touch.y)!=True:
- self.remove_widget(self.menuscreen)
- class MyApp(App):
- def build(self):
- app=RootWidget()
- return app
- if __name__=="__main__":
- MyApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement