Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from kivy.config import Config
- Config.set('kivy', 'exit_on_escape', '0')
- from kivy.app import App
- from kivy.uix.label import Label
- from kivy.uix.boxlayout import BoxLayout
- from kivy.uix.button import Button
- from kivy.uix.popup import Popup
- from kivy.core.window import Window
- class ChildApp(App):
- def build(self):
- Window.bind(on_request_close=self.on_request_close)
- return Label(text='Child')
- def on_request_close(self, *args):
- self.textpopup(title='Exit', text='Are you sure?')
- return True
- def textpopup(self, title='', text=''):
- """Open the pop-up with the name.
- :param title: title of the pop-up to open
- :type title: str
- :param text: main text of the pop-up to open
- :type text: str
- :rtype: None
- """
- box = BoxLayout(orientation='vertical')
- box.add_widget(Label(text=text))
- mybutton = Button(text='OK', size_hint=(1, 0.25))
- box.add_widget(mybutton)
- popup = Popup(title=title, content=box, size_hint=(None, None), size=(600, 300))
- mybutton.bind(on_release=self.stop)
- popup.open()
- if __name__ == '__main__':
- ChildApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement