AGW Logo

agw_title GenericMessageDialog

Main class implementation, GenericMessageDialog is a possible replacement for the standard wx.MessageDialog.

hierarchy Inheritance Diagram

Inheritance diagram for: GenericMessageDialog

Inheritance diagram of GenericMessageDialog


appearance Control Appearance


GenericMessageDialog

GenericMessageDialog


method_summary Methods Summary

__init__Default class constructor.
CreateButtonSizerCreates a sizer with standard buttons.
CreateMessageDialogActually creates the GenericMessageDialog, just before showing it on screen.
CreateSeparatedButtonSizerCreates a sizer with standard buttons using CreateButtonSizer separated
CreateStdDialogButtonSizerCreates a StdDialogButtonSizer with standard buttons.
EndDialogEnds the GenericMessageDialog life. This will be done differently depending on
GetCaptionReturns the main caption (the title) for GenericMessageDialog.
GetCustomCancelBitmapIf a custom icon been used for the Cancel button, this method will return
GetCustomCancelLabelIf a custom label has been used for the Cancel button, this method will return
GetCustomHelpBitmapIf a custom icon has been used for the Help button, this method will return
GetCustomHelpLabelIf a custom label has been used for the Help button, this method will return
GetCustomNoBitmapIf a custom icon has been used for the No button, this method will return
GetCustomNoLabelIf a custom label has been used for the No button, this method will return
GetCustomOKBitmapIf a custom icon has been used for the OK button, this method will return
GetCustomOKLabelIf a custom label has been used for the OK button, this method will return
GetCustomYesBitmapIf a custom icon has been used for the Yes button, this method will return
GetCustomYesLabelIf a custom label has been used for the Yes button, this method will return
GetDefaultCancelBitmapReturns the default icon for the Cancel button.
GetDefaultCancelLabelReturns the default label for the Cancel button.
GetDefaultHelpBitmapReturns the default icon for the Help button.
GetDefaultHelpLabelReturns the default label for the Help button.
GetDefaultNoBitmapReturns the default icon for the No button.
GetDefaultNoLabelReturns the default label for the No button.
GetDefaultOKBitmapReturns the default icon for the OK button.
GetDefaultOKLabelReturns the default label for the OK button.
GetDefaultYesBitmapReturns the default icon for the Yes button.
GetDefaultYesLabelReturns the default label for the Yes button.
GetExtendedMessageReturns a string representing the extended GenericMessageDialog message.
GetFullMessageReturns a string representing the combination of the main GenericMessageDialog
GetMessageReturns a string representing the main GenericMessageDialog message.
GetMessageDialogStyleReturns the AGW-specific window style for GenericMessageDialog.
HasCustomBitmapsReturns True if any of the buttons have a non-default icons.
HasCustomLabelsReturns True if any of the buttons have a non-default label.
OnCancelGenericMessageDialog had received a wx.ID_CANCEL answer.
OnHelpGenericMessageDialog had received a wx.ID_HELP answer.
OnKeyDownHandles the wx.EVT_KEY_DOWN event for GenericMessageDialog.
OnNavigationHandles the wx.EVT_NAVIGATION_KEY event for GenericMessageDialog.
OnNoGenericMessageDialog had received a wx.ID_NO answer.
OnOkGenericMessageDialog had received a wx.ID_OK answer.
OnYesGenericMessageDialog had received a wx.ID_YES answer.
SetExtendedMessageSets the extended message for the dialog: this message is usually an extension of the
SetHelpBitmapOverrides the default icon of the Help button.
SetHelpLabelOverrides the default label of the Help button.
SetMessageSets the message shown by the dialog.
SetOKBitmapOverrides the default icon of the OK button.
SetOKCancelBitmapsOverrides the default icons of the OK and Cancel buttons.
SetOKCancelLabelsOverrides the default labels of the OK and Cancel buttons.
SetOKLabelOverrides the default label of the OK button.
SetYesNoBitmapsOverrides the default icons of the Yes and No buttons.
SetYesNoCancelBitmapsOverrides the default icons of the Yes and No buttons.
SetYesNoCancelLabelsOverrides the default labels of the Yes and No buttons.
SetYesNoLabelsOverrides the default labels of the Yes and No buttons.
ShowModalShows the dialog, returning one of wx.ID_OK, wx.ID_CANCEL, wx.ID_YES,
SwitchFocusSwitch focus between buttons.
WrapMessageWraps the input message to multi lines so that the resulting new message is at most wrap pixels wide.

API Class API

class GenericMessageDialog(wx.Dialog)[source]

Main class implementation, GenericMessageDialog is a possible replacement for the standard wx.MessageDialog.



__init__(parent, message, caption, agwStyle, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE|wx.WANTS_CHARS, wrap=-1)[source]

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
    0 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 and No buttons.
    wx.YES_DEFAULT 0x0 Used with wx.YES_NO, makes Yes button the default - which is the default behaviour.
    wx.NO_DEFAULT 0x80 Used with wx.YES_NO, makes No 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 wx.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(flags)[source]

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 button
wx.OK 0x4 Show an OK button
wx.NO 0x8 Show a No button
wx.CANCEL 0x10 Show a Cancel button
wx.NO_DEFAULT 0x80 Used with wx.YES and wx.NO, makes No button the default
wx.HELP 0x8000 Show a Help button

Note

The sizer lays out the buttons in a manner appropriate to the platform.



CreateMessageDialog()[source]

Actually creates the GenericMessageDialog, just before showing it on screen.



CreateSeparatedButtonSizer(flags)[source]

Creates a sizer with standard buttons using CreateButtonSizer separated from the rest of the dialog contents by a horizontal wx.StaticLine.

Parameters:flags – the button sizer flags.

See also

CreateButtonSizer for a list of valid flags.



CreateStdDialogButtonSizer(flags)[source]

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(rc)[source]

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()[source]

Returns the main caption (the title) for GenericMessageDialog.

New in version 0.9.3.



GetCustomCancelBitmap()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

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()[source]

Returns a string representing the extended GenericMessageDialog message.

New in version 0.9.3.



GetFullMessage()[source]

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()[source]

Returns a string representing the main GenericMessageDialog message.

New in version 0.9.3.



GetMessageDialogStyle()[source]

Returns the AGW-specific window style for GenericMessageDialog.

New in version 0.9.3.



HasCustomBitmaps()[source]

Returns True if any of the buttons have a non-default icons.

New in version 0.9.3.



HasCustomLabels()[source]

Returns True if any of the buttons have a non-default label.

New in version 0.9.3.



OnCancel(event)[source]

GenericMessageDialog had received a wx.ID_CANCEL answer.



OnHelp(event)[source]

GenericMessageDialog had received a wx.ID_HELP answer.



OnKeyDown(event)[source]

Handles the wx.EVT_KEY_DOWN event for GenericMessageDialog.

Parameters:event – a wx.KeyEvent event to be processed.


OnNavigation(event)[source]

Handles the wx.EVT_NAVIGATION_KEY event for GenericMessageDialog.

Parameters:event – a wx.NavigationKeyEvent event to be processed.


OnNo(event)[source]

GenericMessageDialog had received a wx.ID_NO answer.



OnOk(event)[source]

GenericMessageDialog had received a wx.ID_OK answer.



OnYes(event)[source]

GenericMessageDialog had received a wx.ID_YES answer.



SetExtendedMessage(extendedMessage)[source]

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.

New in version 0.9.3.



SetHelpBitmap(helpBitmap)[source]

Overrides the default icon of the Help button.

Parameters:helpBitmap – the new icon for the Help button, an instance of wx.Bitmap.

New in version 0.9.3.



SetHelpLabel(help)[source]

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.

New in version 0.9.3.



SetMessage(message)[source]

Sets the message shown by the dialog.

Parameters:message – a string representing the main GenericMessageDialog message.

New in version 0.9.3.



SetOKBitmap(okBitmap)[source]

Overrides the default icon of the OK button.

Parameters:yesBitmap – the new icon for the OK button, an instance of wx.Bitmap;

New in version 0.9.3.



SetOKCancelBitmaps(okBitmap, cancelBitmap)[source]

Overrides the default icons of the OK and Cancel buttons.

Parameters:
  • okBitmap – the new icon for the OK button, an instance of wx.Bitmap;

  • cancelBitmap – the new icon for the Cancel button, an instance of wx.Bitmap.

New in version 0.9.3.



SetOKCancelLabels(ok, cancel)[source]

Overrides the default labels of the OK and Cancel 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.

New in version 0.9.3.



SetOKLabel(ok)[source]

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.

New in version 0.9.3.



SetYesNoBitmaps(yesBitmap, noBitmap)[source]

Overrides the default icons of the Yes and No buttons.

Parameters:
  • yesBitmap – the new icon for the Yes button, an instance of wx.Bitmap;

  • noBitmap – the new icon for the No button, an instance of wx.Bitmap.

New in version 0.9.3.



SetYesNoCancelBitmaps(yesBitmap, noBitmap, cancelBitmap)[source]

Overrides the default icons of the Yes and No buttons.

Parameters:
  • yesBitmap – the new icon for the Yes button, an instance of wx.Bitmap;

  • noBitmap – the new icon for the No button, an instance of wx.Bitmap;

  • cancelBitmap – the new icon for the Cancel button, an instance of wx.Bitmap.

New in version 0.9.3.



SetYesNoCancelLabels(yes, no, cancel)[source]

Overrides the default labels of the Yes and No 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.

New in version 0.9.3.



SetYesNoLabels(yes, no)[source]

Overrides the default labels of the Yes and No 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?"))

New in version 0.9.3.



ShowModal()[source]

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 wx.MessageBox() function.

Note

Reimplemented from wx.Dialog.



SwitchFocus()[source]

Switch focus between buttons.



WrapMessage(message, wrap, font=None)[source]

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 of wx.Font to be used to measure and then wrap the input message.
Returns:

a new message wrapped at maximum wrap pixels wide.

Todo

Estabilish 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.

Tree

Table Of Contents

Previous topic

genericmessagedialog

Next topic

StdDialogButtonSizer