Skip to content

Popup Windows

Sometimes your app needs to stop everything to tell the user something important or ask a quick question. In GooeyPie, we use Popups (also called modal dialogs) for this.These windows “float” on top of your app and must be dismissed before the user can go back to the main window.

Every popup requires a category. This decides which icon is displayed and helps the user understand the “vibe” of the message:

ValueIconDescription
'info'General information or updates.
'warning'Alerts that require user caution.
'error'Indicates a problem that has occurred.
'question'Used when asking the user to make a choice.

Use an alert when you just want to give information and only need the user to click “OK”.

snippet_alert layout example
app.alert("Victory!", "You reached the high score!", "info")

Note: The alert() method doesn’t return any value because there’s only one button to click!.

These popups return a value based on what the user clicks. Here’s a quick reference for the different question popups:

MethodButtons ShownReturns…
app.ask_yes_no()Yes, NoTrue (Yes) or False (No)
app.ask_ok_cancel()OK, CancelTrue (OK) or False (Cancel)
app.ask_yes_no_cancel()Yes, No, CancelTrue (Yes), False (No), or None (Cancel)
snippet_warning layout example
app.ask_ok_cancel("Confirm Delete", "This will delete all progress.\n\nThis operation cannot be undone. Are you sure you want to proceed?", "warning")

A common use for ask_yes_no is making sure a user actually wants to quit. You can combine this with the on_quit method of your app.

def confirm_exit(event):
# This popup returns True or False
should_exit = app.ask_yes_no("Confirm", "Do you really want to quit?", "question")
return should_exit
app.on_quit(confirm_exit)