Class MsgBox

Straight forward message box for displaying messages on screen.

from ooodev.dialog.msgbox import MsgBox, MessageBoxType, MessageBoxButtonsEnum, MessageBoxResultsEnum

result = MsgBox.msgbox(
    "Are you sure?",
    boxtype=MessageBoxType.QUERYBOX,
    buttons=MessageBoxButtonsEnum.BUTTONS_YES_NO
    )

if result == MessageBoxResultsEnum.Results.YES:
    print("All is OK")
elif result == MessageBoxResultsEnum.Results.NO:
    print("No is the choice!")
class ooodev.dialog.msgbox.MsgBox[source]
static msgbox(msg, title='Message', boxtype=MessageBoxType.MESSAGEBOX, buttons=MessageBoxButtonsEnum.BUTTONS_OK)[source]

Simple message box.

Parameters:
  • msg (str) – the message for display.

  • title (str, optional) – the title of the message box. Defaults to “Message”.

  • boxtype (MessageBoxType, int, optional) – determines the type of message box to display. Defaults to Type.MESSAGEBOX.

  • buttons (MessageBoxButtonsEnum, int, optional) – determines what buttons to display. Defaults to Buttons.BUTTONS_OK.

Returns:

MessageBoxResultsEnum.

Return type:

Results

Note

If boxtype is an integer, the following values are valid:

  • 0: MESSAGEBOX

  • 1: INFOBOX

  • 2: WARNINGBOX

  • 3: ERRORBOX

  • 4: QUERYBOX

Note

  • Button press Abort returns MessageBoxResultsEnum.CANCEL

  • Button press Cancel returns MessageBoxResultsEnum.CANCEL

  • Button press Ignore returns MessageBoxResultsEnum.IGNORE

  • Button press No returns MessageBoxResultsEnum.NO

  • Button press OK returns MessageBoxResultsEnum.OK

  • Button press Retry returns MessageBoxResultsEnum.RETRY

  • Button press Yes returns MessageBoxResultsEnum.YES

Note

Raises a global event GblNamedEvent.MSG_BOX_CREATING before creating the dialog. The event args are of type CancelEventArgs. The event_data is a dictionary that contains the following key:

  • msg: The message to display.

  • title: The title of the dialog.

  • boxtype: The type of message box to display.

  • buttons: The buttons to display.

If the event is cancelled, the result value of event_data` if set will be returned. Otherwise if the event is not handled, a ``CancelEventError is raised.

Hint

  • MessageBoxResultsEnum can be imported from ooo.dyn.awt.message_box_results.

  • MessageBoxButtonsEnum can be imported from ooo.dyn.awt.message_box_buttons.

  • MessageBoxType can be imported from ooo.dyn.awt.message_box_type.

Changed in version 0.38.1: Now boxtype can also be an integer value.