【Kivy】Popup を表示する

  • main.py
from kivy.app import App

class MainApp(App):
    pass

if __name__ == '__main__':
    MainApp().run()
  • main.kv
#:kivy 1.0
#:import Factory kivy.factory.Factory
<MyPopup@Popup>:
    auto_dismiss: False
    size_hint: .5, .5
    pos_hint: {'center_x': .5, 'center_y': .5}
    title: 'Title'
    BoxLayout:
        orientation: 'vertical'
        Label:
            text: 'Hello World'
        Button:
            size_hint_y: None
            height: 80
            text: 'Close'
            on_release: root.dismiss()

Button:
    text: 'Open Popup'
    on_release: Factory.MyPopup().open()