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
boxtypeis an integer, the following values are valid:0:
MESSAGEBOX1:
INFOBOX2:
WARNINGBOX3:
ERRORBOX4:
QUERYBOX
Note
Button press
AbortreturnsMessageBoxResultsEnum.CANCELButton press
CancelreturnsMessageBoxResultsEnum.CANCELButton press
IgnorereturnsMessageBoxResultsEnum.IGNOREButton press
NoreturnsMessageBoxResultsEnum.NOButton press
OKreturnsMessageBoxResultsEnum.OKButton press
RetryreturnsMessageBoxResultsEnum.RETRYButton press
YesreturnsMessageBoxResultsEnum.YES
Note
Raises a global event
GblNamedEvent.MSG_BOX_CREATINGbefore creating the dialog. The event args are of typeCancelEventArgs. Theevent_datais 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
resultvalue ofevent_data` if set will be returned. Otherwise if the event is not handled, a ``CancelEventErroris raised.Hint
MessageBoxResultsEnumcan be imported fromooo.dyn.awt.message_box_results.MessageBoxButtonsEnumcan be imported fromooo.dyn.awt.message_box_buttons.MessageBoxTypecan be imported fromooo.dyn.awt.message_box_type.
Changed in version 0.38.1: Now
boxtypecan also be an integer value.