Main class implementation, GenericMessageDialog
is a possible replacement
for the standard MessageDialog
.
Default class constructor. Use |
|
Creates a sizer with standard buttons. |
|
Actually creates the |
|
Creates a sizer with standard buttons using |
|
Creates a |
|
Ends the |
|
Returns the main caption (the title) for |
|
If a custom icon been used for the |
|
If a custom label has been used for the |
|
If a custom icon has been used for the |
|
If a custom label has been used for the |
|
If a custom icon has been used for the |
|
If a custom label has been used for the |
|
If a custom icon has been used for the |
|
If a custom label has been used for the |
|
If a custom icon has been used for the |
|
If a custom label has been used for the |
|
Returns the default icon for the |
|
Returns the default label for the |
|
Returns the default icon for the |
|
Returns the default label for the |
|
Returns the default icon for the |
|
Returns the default label for the |
|
Returns the default icon for the |
|
Returns the default label for the |
|
Returns the default icon for the |
|
Returns the default label for the |
|
Returns a string representing the extended |
|
Returns a string representing the combination of the main |
|
Returns a string representing the main |
|
Returns the AGW-specific window style for |
|
Returns |
|
Returns |
|
|
|
|
|
Handles the |
|
Handles the |
|
|
|
|
|
|
|
Sets the extended message for the dialog: this message is usually an extension of the |
|
Overrides the default icon of the |
|
Overrides the default label of the |
|
Sets the message shown by the dialog. |
|
Overrides the default icon of the |
|
Overrides the default icons of the |
|
Overrides the default labels of the |
|
Overrides the default label of the |
|
Overrides the default icons of the |
|
Overrides the default icons of the |
|
Overrides the default labels of the |
|
Overrides the default labels of the |
|
Shows the dialog, returning one of |
|
Switch focus between buttons. |
|
Wraps the input message to multi lines so that the resulting new message |
GenericMessageDialog
(wx.Dialog)¶Main class implementation, GenericMessageDialog
is a possible replacement
for the standard MessageDialog
.
__init__
(self, parent, message, caption, agwStyle, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE | wx.WANTS_CHARS, wrap=-1)¶Default class constructor. Use ShowModal
to show the dialog.
parent – the GenericMessageDialog
parent (if any);
message – the message in the main body of the dialog;
caption – the dialog title;
agwStyle –
the AGW-specific dialog style; it can be one of the following bits:
Window Styles |
Hex Value |
Description |
---|---|---|
|
0 |
Uses normal generic buttons |
|
0x20 |
Uses |
|
0x40 |
Uses |
The styles above are mutually exclusive. The style chosen above can be combined with a bitlist containing flags chosen from the following:
Window Styles |
Hex Value |
Description |
---|---|---|
|
0x4 |
Shows an |
|
0x10 |
Shows a |
|
0xA |
Show |
|
0x0 |
Used with |
|
0x80 |
Used with |
|
0x100 |
Shows an exclamation mark icon. |
|
0x200 |
Shows an error icon. |
|
0x200 |
Shows an error icon - the same as |
|
0x400 |
Shows a question mark icon. |
|
0x800 |
Shows an information icon. |
pos – the dialog position on screen;
size – the dialog size;
style – the underlying Dialog
style;
wrap – if set greater than zero, wraps the string in message so that every line is at most wrap pixels long.
Note
Notice that not all styles are compatible: only one of wx.OK
and wx.YES_NO
may be
specified (and one of them must be specified) and at most one default button style can be used
and it is only valid if the corresponding button is shown in the message box.
CreateButtonSizer
(self, flags)¶Creates a sizer with standard buttons.
flags – a bit list of the following flags:
Flags |
Hex Value |
Description |
---|---|---|
|
0x2 |
Show a |
|
0x4 |
Show an |
|
0x8 |
Show a |
|
0x10 |
Show a |
|
0x80 |
Used with |
|
0x8000 |
Show a |
Note
The sizer lays out the buttons in a manner appropriate to the platform.
CreateMessageDialog
(self)¶Actually creates the GenericMessageDialog
, just before showing it on screen.
CreateSeparatedButtonSizer
(self, flags)¶Creates a sizer with standard buttons using CreateButtonSizer
separated
from the rest of the dialog contents by a horizontal StaticLine
.
flags – the button sizer flags.
See also
CreateButtonSizer
for a list of valid flags.
CreateStdDialogButtonSizer
(self, flags)¶Creates a StdDialogButtonSizer
with standard buttons.
flags – the button sizer flags.
See also
CreateButtonSizer
for a list of valid flags.
Note
The sizer lays out the buttons in a manner appropriate to the platform.
EndDialog
(self, rc)¶Ends the GenericMessageDialog
life. This will be done differently depending on
the dialog modal/non-modal behaviour.
rc – one of the wx.ID_YES
, wx.ID_NO
, wx.ID_OK
, wx.ID_CANCEL
constants.
Note
the rc parameter is unused if the dialog is not modal.
GetCaption
(self)¶Returns the main caption (the title) for GenericMessageDialog
.
New in version 0.9.3.
GetCustomCancelBitmap
(self)¶If a custom icon been used for the Cancel
button, this method will return
it as an instance of wx.Bitmap
. Otherwise, the default one (as defined in
GetDefaultCancelBitmap
) is returned.
New in version 0.9.3.
GetCustomCancelLabel
(self)¶If a custom label has been used for the Cancel
button, this method will return
it as a string. Otherwise, the default one (as defined in GetDefaultCancelLabel
)
is returned.
New in version 0.9.3.
GetCustomHelpBitmap
(self)¶If a custom icon has been used for the Help
button, this method will return
it as an instance of wx.Bitmap
. Otherwise, the default one (as defined in
GetDefaultHelpBitmap
) is returned.
New in version 0.9.3.
GetCustomHelpLabel
(self)¶If a custom label has been used for the Help
button, this method will return
it as a string. Otherwise, the default one (as defined in GetDefaultHelpLabel
)
is returned.
New in version 0.9.3.
GetCustomNoBitmap
(self)¶If a custom icon has been used for the No
button, this method will return
it as an instance of wx.Bitmap
. Otherwise, the default one (as defined in
GetDefaultNoBitmap
) is returned.
New in version 0.9.3.
GetCustomNoLabel
(self)¶If a custom label has been used for the No
button, this method will return
it as a string. Otherwise, the default one (as defined in GetDefaultNoLabel
)
is returned.
New in version 0.9.3.
GetCustomOKBitmap
(self)¶If a custom icon has been used for the OK
button, this method will return
it as an instance of wx.Bitmap
. Otherwise, the default one (as defined in
GetDefaultOKBitmap
) is returned.
New in version 0.9.3.
GetCustomOKLabel
(self)¶If a custom label has been used for the OK
button, this method will return
it as a string. Otherwise, the default one (as defined in GetDefaultOKLabel
)
is returned.
New in version 0.9.3.
GetCustomYesBitmap
(self)¶If a custom icon has been used for the Yes
button, this method will return
it as an instance of wx.Bitmap
. Otherwise, the default one (as defined in
GetDefaultYesBitmap
) is returned.
New in version 0.9.3.
GetCustomYesLabel
(self)¶If a custom label has been used for the Yes
button, this method will return
it as a string. Otherwise, the default one (as defined in GetDefaultYesLabel
)
is returned.
New in version 0.9.3.
GetDefaultCancelBitmap
(self)¶Returns the default icon for the Cancel
button.
Note
this method may be overridden to provide different defaults for the default button icons.
New in version 0.9.3.
GetDefaultCancelLabel
(self)¶Returns the default label for the Cancel
button.
Note
this method may be overridden to provide different defaults for the default button labels.
New in version 0.9.3.
GetDefaultHelpBitmap
(self)¶Returns the default icon for the Help
button.
Note
this method may be overridden to provide different defaults for the default button icons.
New in version 0.9.3.
GetDefaultHelpLabel
(self)¶Returns the default label for the Help
button.
Note
this method may be overridden to provide different defaults for the default button labels.
New in version 0.9.3.
GetDefaultNoBitmap
(self)¶Returns the default icon for the No
button.
Note
this method may be overridden to provide different defaults for the default button icons.
New in version 0.9.3.
GetDefaultNoLabel
(self)¶Returns the default label for the No
button.
Note
this method may be overridden to provide different defaults for the default button labels.
New in version 0.9.3.
GetDefaultOKBitmap
(self)¶Returns the default icon for the OK
button.
Note
this method may be overridden to provide different defaults for the default button icons.
New in version 0.9.3.
GetDefaultOKLabel
(self)¶Returns the default label for the OK
button.
Note
this method may be overridden to provide different defaults for the default button labels.
New in version 0.9.3.
GetDefaultYesBitmap
(self)¶Returns the default icon for the Yes
button.
Note
this method may be overridden to provide different defaults for the default button icons.
New in version 0.9.3.
GetDefaultYesLabel
(self)¶Returns the default label for the Yes
button.
Note
this method may be overridden to provide different defaults for the default button labels.
New in version 0.9.3.
GetExtendedMessage
(self)¶Returns a string representing the extended GenericMessageDialog
message.
New in version 0.9.3.
GetFullMessage
(self)¶Returns a string representing the combination of the main GenericMessageDialog
message and the extended message, separated by an empty line.
New in version 0.9.3.
GetMessage
(self)¶Returns a string representing the main GenericMessageDialog
message.
New in version 0.9.3.
GetMessageDialogStyle
(self)¶Returns the AGW-specific window style for GenericMessageDialog
.
New in version 0.9.3.
HasCustomBitmaps
(self)¶Returns True
if any of the buttons have a non-default icons.
New in version 0.9.3.
HasCustomLabels
(self)¶Returns True
if any of the buttons have a non-default label.
New in version 0.9.3.
OnCancel
(self, event)¶GenericMessageDialog
had received a wx.ID_CANCEL
answer.
OnHelp
(self, event)¶GenericMessageDialog
had received a wx.ID_HELP
answer.
OnKeyDown
(self, event)¶Handles the wx.EVT_KEY_DOWN
event for GenericMessageDialog
.
event – a KeyEvent
event to be processed.
Handles the wx.EVT_NAVIGATION_KEY
event for GenericMessageDialog
.
event – a NavigationKeyEvent
event to be processed.
OnNo
(self, event)¶GenericMessageDialog
had received a wx.ID_NO
answer.
OnOk
(self, event)¶GenericMessageDialog
had received a wx.ID_OK
answer.
OnYes
(self, event)¶GenericMessageDialog
had received a wx.ID_YES
answer.
SetExtendedMessage
(self, extendedMessage)¶Sets the extended message for the dialog: this message is usually an extension of the
short message specified in the constructor or set with SetMessage
.
If it is set, the main message appears highlighted and this message appears beneath it in normal font.
extendedMessage – a string representing the extended GenericMessageDialog
message.
New in version 0.9.3.
SetHelpBitmap
(self, helpBitmap)¶Overrides the default icon of the Help
button.
helpBitmap – the new icon for the Help
button, an instance of wx.Bitmap
.
New in version 0.9.3.
SetHelpLabel
(self, help)¶Overrides the default label of the Help
button.
help – the new label for the Help
button.
SetMessage
(self, message)¶Sets the message shown by the dialog.
message – a string representing the main GenericMessageDialog
message.
New in version 0.9.3.
SetOKBitmap
(self, okBitmap)¶Overrides the default icon of the OK
button.
yesBitmap – the new icon for the OK
button, an instance of wx.Bitmap
;
New in version 0.9.3.
SetOKCancelBitmaps
(self, okBitmap, cancelBitmap)¶Overrides the default icons of the OK
and Cancel
buttons.
New in version 0.9.3.
SetOKCancelLabels
(self, ok, cancel)¶Overrides the default labels of the OK
and Cancel
buttons.
ok – the new label for the OK
button;
cancel – the new label for the Cancel
button.
SetOKLabel
(self, ok)¶Overrides the default label of the OK
button.
ok – the new label for the OK
button.
SetYesNoBitmaps
(self, yesBitmap, noBitmap)¶Overrides the default icons of the Yes
and No
buttons.
New in version 0.9.3.
SetYesNoCancelBitmaps
(self, yesBitmap, noBitmap, cancelBitmap)¶Overrides the default icons of the Yes
and No
buttons.
New in version 0.9.3.
SetYesNoCancelLabels
(self, yes, no, cancel)¶Overrides the default labels of the Yes
and No
buttons.
yes – the new label for the Yes
button;
no – the new label for the No
button;
cancel – the new label for the Cancel
button.
SetYesNoLabels
(self, yes, no)¶Overrides the default labels of the Yes
and No
buttons.
yes – the new label for the Yes
button;
no – the new label for the No
button.
Typically, if the function was used successfully, the main dialog message may need to be changed, e.g.:
main_message = "Hello world! I am the main message."
dlg = GenericMessageDialog(None, main_message, "A Nice Message Box",
agwStyle=wx.ICON_INFORMATION | wx.OK)
if dlg.SetYesNoLabels(_("&Quit"), _("&Don't quit")):
dlg.SetMessage(_("What do you want to do?"))
else: # buttons have standard "Yes"/"No" values, so rephrase the question
dlg.SetMessage(_("Do you really want to quit?"))
New in version 0.9.3.
ShowModal
(self)¶Shows the dialog, returning one of wx.ID_OK
, wx.ID_CANCEL
, wx.ID_YES
,
wx.ID_NO
or wx.ID_HELP
.
Note
Notice that this method returns the identifier of the button which was
clicked unlike the MessageBox
() function.
Note
Reimplemented from Dialog
.
SwitchFocus
(self)¶Switch focus between buttons.
WrapMessage
(self, message, wrap, font=None)¶Wraps the input message to multi lines so that the resulting new message is at most wrap pixels wide.
message – the original input message;
wrap – wraps the string in message so that every line is at most wrap pixels long;
font – if not None
, it should be an instance of wx.Font
to be
used to measure and then wrap the input message.
a new message wrapped at maximum wrap pixels wide.
Establish if wrapping all messages by default is a better idea than
provide a keyword parameter to GenericMessageDialog
. A default maximum
line width might be the wxMac one, at 360 pixels.