wx.lib.agw.genericmessagedialog.GenericMessageDialog¶
Main class implementation, GenericMessageDialog
is a possible replacement
for the standard MessageDialog
.
Class Hierarchy¶
Control Appearance¶
Known Superclasses¶
Methods Summary¶
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 |
Class API¶
- class GenericMessageDialog(wx.Dialog)¶
Main class implementation,
GenericMessageDialog
is a possible replacement for the standardMessageDialog
.
Methods¶
- __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.- Parameters:
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
GMD_DEFAULT
0
Uses normal generic buttons
GMD_USE_AQUABUTTONS
0x20
Uses
AquaButton
buttons instead of generic buttons.GMD_USE_GRADIENTBUTTONS
0x40
Uses
GradientButton
buttons instead of generic buttons.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
wx.OK
0x4
Shows an
OK
button.wx.CANCEL
0x10
Shows a
Cancel
button.wx.YES_NO
0xA
Show
Yes
andNo
buttons.wx.YES_DEFAULT
0x0
Used with
wx.YES_NO
, makesYes
button the default - which is the default behaviour.wx.NO_DEFAULT
0x80
Used with
wx.YES_NO
, makesNo
button the default.wx.ICON_EXCLAMATION
0x100
Shows an exclamation mark icon.
wx.ICON_HAND
0x200
Shows an error icon.
wx.ICON_ERROR
0x200
Shows an error icon - the same as
wx.ICON_HAND
.wx.ICON_QUESTION
0x400
Shows a question mark icon.
wx.ICON_INFORMATION
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
andwx.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.
- Parameters:
flags – a bit list of the following flags:
Flags
Hex Value
Description
wx.YES
0x2
Show a
Yes
buttonwx.OK
0x4
Show an
OK
buttonwx.NO
0x8
Show a
No
buttonwx.CANCEL
0x10
Show a
Cancel
buttonwx.NO_DEFAULT
0x80
Used with
wx.YES
andwx.NO
, makesNo
button the defaultwx.HELP
0x8000
Show a
Help
button
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 horizontalStaticLine
.- Parameters:
flags – the button sizer flags.
See also
CreateButtonSizer
for a list of valid flags.
- CreateStdDialogButtonSizer(self, flags)¶
Creates a
StdDialogButtonSizer
with standard buttons.- Parameters:
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.- Parameters:
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
.Added 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 ofwx.Bitmap
. Otherwise, the default one (as defined inGetDefaultCancelBitmap
) is returned.Added 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 inGetDefaultCancelLabel
) is returned.Added 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 ofwx.Bitmap
. Otherwise, the default one (as defined inGetDefaultHelpBitmap
) is returned.Added 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 inGetDefaultHelpLabel
) is returned.Added 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 ofwx.Bitmap
. Otherwise, the default one (as defined inGetDefaultNoBitmap
) is returned.Added 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 inGetDefaultNoLabel
) is returned.Added 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 ofwx.Bitmap
. Otherwise, the default one (as defined inGetDefaultOKBitmap
) is returned.Added 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 inGetDefaultOKLabel
) is returned.Added 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 ofwx.Bitmap
. Otherwise, the default one (as defined inGetDefaultYesBitmap
) is returned.Added 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 inGetDefaultYesLabel
) is returned.Added 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.
Added 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.
Added 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.
Added 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.
Added 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.
Added 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.
Added 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.
Added 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.
Added 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.
Added 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.
Added in version 0.9.3.
- GetExtendedMessage(self)¶
Returns a string representing the extended
GenericMessageDialog
message.Added 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.Added in version 0.9.3.
- GetMessage(self)¶
Returns a string representing the main
GenericMessageDialog
message.Added in version 0.9.3.
- GetMessageDialogStyle(self)¶
Returns the AGW-specific window style for
GenericMessageDialog
.Added in version 0.9.3.
- HasCustomBitmaps(self)¶
Returns
True
if any of the buttons have a non-default icons.Added in version 0.9.3.
- HasCustomLabels(self)¶
Returns
True
if any of the buttons have a non-default label.Added in version 0.9.3.
- OnCancel(self, event)¶
GenericMessageDialog
had received awx.ID_CANCEL
answer.
- OnHelp(self, event)¶
GenericMessageDialog
had received awx.ID_HELP
answer.
- OnKeyDown(self, event)¶
Handles the
wx.EVT_KEY_DOWN
event forGenericMessageDialog
.- Parameters:
event – a
KeyEvent
event to be processed.
Handles the
wx.EVT_NAVIGATION_KEY
event forGenericMessageDialog
.- Parameters:
event – a
NavigationKeyEvent
event to be processed.
- OnNo(self, event)¶
GenericMessageDialog
had received awx.ID_NO
answer.
- OnOk(self, event)¶
GenericMessageDialog
had received awx.ID_OK
answer.
- OnYes(self, event)¶
GenericMessageDialog
had received awx.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.
- Parameters:
extendedMessage – a string representing the extended
GenericMessageDialog
message.
Added in version 0.9.3.
- SetHelpBitmap(self, helpBitmap)¶
Overrides the default icon of the
Help
button.- Parameters:
helpBitmap – the new icon for the
Help
button, an instance ofwx.Bitmap
.
Added in version 0.9.3.
- SetHelpLabel(self, help)¶
Overrides the default label of the
Help
button.- Parameters:
help – the new label for the
Help
button.
See also
The remarks in the
SetYesNoLabels
documentation.Added in version 0.9.3.
- SetMessage(self, message)¶
Sets the message shown by the dialog.
- Parameters:
message – a string representing the main
GenericMessageDialog
message.
Added in version 0.9.3.
- SetOKBitmap(self, okBitmap)¶
Overrides the default icon of the
OK
button.- Parameters:
yesBitmap – the new icon for the
OK
button, an instance ofwx.Bitmap
;
Added in version 0.9.3.
- SetOKCancelBitmaps(self, okBitmap, cancelBitmap)¶
Overrides the default icons of the
OK
andCancel
buttons.- Parameters:
Added in version 0.9.3.
- SetOKCancelLabels(self, ok, cancel)¶
Overrides the default labels of the
OK
andCancel
buttons.- Parameters:
ok – the new label for the
OK
button;cancel – the new label for the
Cancel
button.
See also
The remarks in the
SetYesNoLabels
documentation.Added in version 0.9.3.
- SetOKLabel(self, ok)¶
Overrides the default label of the
OK
button.- Parameters:
ok – the new label for the
OK
button.
See also
The remarks in the
SetYesNoLabels
documentation.Added in version 0.9.3.
- SetYesNoBitmaps(self, yesBitmap, noBitmap)¶
Overrides the default icons of the
Yes
andNo
buttons.- Parameters:
Added in version 0.9.3.
- SetYesNoCancelBitmaps(self, yesBitmap, noBitmap, cancelBitmap)¶
Overrides the default icons of the
Yes
andNo
buttons.- Parameters:
Added in version 0.9.3.
- SetYesNoCancelLabels(self, yes, no, cancel)¶
Overrides the default labels of the
Yes
andNo
buttons.- Parameters:
yes – the new label for the
Yes
button;no – the new label for the
No
button;cancel – the new label for the
Cancel
button.
See also
The remarks in the
SetYesNoLabels
documentation.Added in version 0.9.3.
- SetYesNoLabels(self, yes, no)¶
Overrides the default labels of the
Yes
andNo
buttons.- Parameters:
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?"))
Added 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
orwx.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.
- Parameters:
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 ofwx.Font
to be used to measure and then wrap the input message.
- Returns:
a new message wrapped at maximum wrap pixels wide.
- Todo:
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.