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
returnsMessageBoxResultsEnum.CANCEL
Button press
Cancel
returnsMessageBoxResultsEnum.CANCEL
Button press
Ignore
returnsMessageBoxResultsEnum.IGNORE
Button press
No
returnsMessageBoxResultsEnum.NO
Button press
OK
returnsMessageBoxResultsEnum.OK
Button press
Retry
returnsMessageBoxResultsEnum.RETRY
Button press
Yes
returnsMessageBoxResultsEnum.YES
Note
Raises a global event
GblNamedEvent.MSG_BOX_CREATING
before creating the dialog. The event args are of typeCancelEventArgs
. Theevent_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 ofevent_data` if set will be returned. Otherwise if the event is not handled, a ``CancelEventError
is raised.Hint
MessageBoxResultsEnum
can be imported fromooo.dyn.awt.message_box_results
.MessageBoxButtonsEnum
can be imported fromooo.dyn.awt.message_box_buttons
.MessageBoxType
can be imported fromooo.dyn.awt.message_box_type
.
Changed in version 0.38.1: Now
boxtype
can also be an integer value.