Messagebox#

Messagebox shows a modal message dialog and returns which button the user clicked. Every method is a static method — call it on the class, no instance needed (Messagebox.show_info("Saved.")). Each blocks until the user responds and returns the clicked button’s text, or None if the dialog is closed.

Common parameters#

Every method takes message and title positionally, plus these keyword-only options:

Option

Type

Description

parent

Widget

The window to center over and block while open. Defaults to the application root.

alert

bool

Ring the display bell when the dialog appears.

position

tuple

An (x, y) top-left screen position. Centered on parent by default.

buttons

list

Override the buttons — a list of labels, each optionally "label:bootstyle" to color it (e.g. "OK:success"). The label is also what the method returns.

icon

str

A Bootstrap Icons glyph name shown beside the message.

localize

bool

Translate the standard button labels through the message catalog. Default True.

Methods#

static show_info(message, title=' ', *, parent=None, alert=False, position=None, buttons=None, icon=None, localize=True)

An informational message with an info icon and an OK button.

Returns:

the clicked button’s text, or None.

static show_warning(message, title=' ', *, parent=None, alert=True, position=None, buttons=None, icon=None, localize=True)

A warning message with a warning icon and an OK button. Rings the bell by default.

Returns:

the clicked button’s text, or None.

static show_error(message, title=' ', *, parent=None, alert=True, position=None, buttons=None, icon=None, localize=True)

An error message with an error icon and an OK button. Rings the bell by default.

Returns:

the clicked button’s text, or None.

static show_question(message, title=' ', *, parent=None, alert=False, position=None, buttons=None, icon=None, localize=True)

A message with a question icon and an OK button. Pass buttons for a different choice set.

Returns:

the clicked button’s text, or None.

static ok(message, title=' ', *, parent=None, alert=False, position=None, buttons=None, icon=None, localize=True)

A message with a single OK button.

Returns:

"OK", or None if closed.

static okcancel(message, title=' ', *, parent=None, alert=False, position=None, buttons=None, icon=None, localize=True)

A message with OK and Cancel buttons.

Returns:

"OK" or "Cancel", or None if closed.

static yesno(message, title=' ', *, parent=None, alert=False, position=None, buttons=None, icon=None, localize=True)

A message with Yes and No buttons.

Returns:

"Yes" or "No", or None if closed.

static yesnocancel(message, title=' ', *, parent=None, alert=False, position=None, buttons=None, icon=None, localize=True)

A message with Yes, No, and Cancel buttons.

Returns:

"Yes", "No", or "Cancel", or None if closed.

static retrycancel(message, title=' ', *, parent=None, alert=False, position=None, buttons=None, icon=None, localize=True)

A message with Retry and Cancel buttons.

Returns:

"Retry" or "Cancel", or None if closed.

See also#

  • Dialogs — how to use them, with examples.

  • Querybox — the input-and-picker facade.

  • MessageDialog — the dialog class Messagebox builds, for full control.