Popup

New in version 1.0.7.

_images/popup.jpg

The Popup widget is used to create modal popups. By default, the popup will cover the whole “parent” window. When you are creating a Popup, you must at minimum set a Popup.title and a Popup.content widget.

Remember that the default size of a Widget is size_hint=(1, 1). If you don’t want your popup to be fullscreen, deactivate the size_hint and use a specific size attribute.

Examples

Example of a simple 400x400 Hello world popup:

popup = Popup(title='Test popup',
    content=Label(text='Hello world'),
    size_hint=(None, None), size=(400, 400))

By default, any click outside the popup will dismiss it. If you don’t want that, you can set Popup.auto_dismiss to False:

popup = Popup(title='Test popup', content=Label(text='Hello world'),
              auto_dismiss=False)
popup.open()

To manually dismiss/close the popup, use Popup.dismiss():

popup.dismiss()

The Popup.open() and Popup.dismiss() are bindable. That means you can directly bind the function to an action, like an a Button’s on_press

# create content and assign to the popup
content = Button(text='Close me!')
popup = Popup(content=content, auto_dismiss=False)

# bind the on_press event of the button to the our dismiss function
content.bind(on_press=popup.dismiss)

# open the popup
popup.open()