phoenix_title wx.lib.agw.genericmessagedialog.GenericMessageDialog

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


class_hierarchy Class Hierarchy

Inheritance diagram for class GenericMessageDialog:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


super_classes Known Superclasses

wx.Dialog


method_summary Methods Summary

__init__

Default class constructor. Use ShowModal to show the dialog.

CreateButtonSizer

Creates a sizer with standard buttons.

CreateMessageDialog

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

CreateSeparatedButtonSizer

Creates a sizer with standard buttons using CreateButtonSizer separated

CreateStdDialogButtonSizer

Creates a StdDialogButtonSizer with standard buttons.

EndDialog

Ends the GenericMessageDialog life. This will be done differently depending on

GetCaption

Returns the main caption (the title) for GenericMessageDialog.

GetCustomCancelBitmap

If a custom icon been used for the Cancel button, this method will return

GetCustomCancelLabel

If a custom label has been used for the Cancel button, this method will return

GetCustomHelpBitmap

If a custom icon has been used for the Help button, this method will return

GetCustomHelpLabel

If a custom label has been used for the Help button, this method will return

GetCustomNoBitmap

If a custom icon has been used for the No button, this method will return

GetCustomNoLabel

If a custom label has been used for the No button, this method will return

GetCustomOKBitmap

If a custom icon has been used for the OK button, this method will return

GetCustomOKLabel

If a custom label has been used for the OK button, this method will return

GetCustomYesBitmap

If a custom icon has been used for the Yes button, this method will return

GetCustomYesLabel

If a custom label has been used for the Yes button, this method will return

GetDefaultCancelBitmap

Returns the default icon for the Cancel button.

GetDefaultCancelLabel

Returns the default label for the Cancel button.

GetDefaultHelpBitmap

Returns the default icon for the Help button.

GetDefaultHelpLabel

Returns the default label for the Help button.

GetDefaultNoBitmap

Returns the default icon for the No button.

GetDefaultNoLabel

Returns the default label for the No button.

GetDefaultOKBitmap

Returns the default icon for the OK button.

GetDefaultOKLabel

Returns the default label for the OK button.

GetDefaultYesBitmap

Returns the default icon for the Yes button.

GetDefaultYesLabel

Returns the default label for the Yes button.

GetExtendedMessage

Returns a string representing the extended GenericMessageDialog message.

GetFullMessage

Returns a string representing the combination of the main GenericMessageDialog

GetMessage

Returns a string representing the main GenericMessageDialog message.

GetMessageDialogStyle

Returns the AGW-specific window style for GenericMessageDialog.

HasCustomBitmaps

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

HasCustomLabels

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

OnCancel

GenericMessageDialog had received a wx.ID_CANCEL answer.

OnHelp

GenericMessageDialog had received a wx.ID_HELP answer.

OnKeyDown

Handles the wx.EVT_KEY_DOWN event for GenericMessageDialog.

OnNavigation

Handles the wx.EVT_NAVIGATION_KEY event for GenericMessageDialog.

OnNo

GenericMessageDialog had received a wx.ID_NO answer.

OnOk

GenericMessageDialog had received a wx.ID_OK answer.

OnYes

GenericMessageDialog had received a wx.ID_YES answer.

SetExtendedMessage

Sets the extended message for the dialog: this message is usually an extension of the

SetHelpBitmap

Overrides the default icon of the Help button.

SetHelpLabel

Overrides the default label of the Help button.

SetMessage

Sets the message shown by the dialog.

SetOKBitmap

Overrides the default icon of the OK button.

SetOKCancelBitmaps

Overrides the default icons of the OK and Cancel buttons.

SetOKCancelLabels

Overrides the default labels of the OK and Cancel buttons.

SetOKLabel

Overrides the default label of the OK button.

SetYesNoBitmaps

Overrides the default icons of the Yes and No buttons.

SetYesNoCancelBitmaps

Overrides the default icons of the Yes and No buttons.

SetYesNoCancelLabels

Overrides the default labels of the Yes and No buttons.

SetYesNoLabels

Overrides the default labels of the Yes and No buttons.

ShowModal

Shows the dialog, returning one of wx.ID_OK, wx.ID_CANCEL, wx.ID_YES,

SwitchFocus

Switch focus between buttons.

WrapMessage

Wraps the input message to multi lines so that the resulting new message


api Class API

class GenericMessageDialog(wx.Dialog)

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


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

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

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.

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.

Parameters

event – a KeyEvent event to be processed.



OnNavigation(self, event)

Handles the wx.EVT_NAVIGATION_KEY event for GenericMessageDialog.

Parameters

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.

Parameters

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.

Parameters

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.

Parameters

help – the new label for the Help button.

See also

The remarks in the SetYesNoLabels documentation.

New in version 0.9.3.



SetMessage(self, message)

Sets the message shown by the dialog.

Parameters

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.

Parameters

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.

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(self, ok, cancel)

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

New in version 0.9.3.



SetYesNoBitmaps(self, yesBitmap, noBitmap)

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(self, yesBitmap, noBitmap, cancelBitmap)

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(self, yes, no, cancel)

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(self, yes, no)

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

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.