Name

gtk.MessageDialog — a convenient message window

Synopsis

class gtk.MessageDialog(gtk.Dialog):
    gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_NONE, message_format=None)
def set_markup(str)

Ancestry

+-- gobject.GObject
  +-- gtk.Object
    +-- gtk.Widget
      +-- gtk.Container
        +-- gtk.Bin
          +-- gtk.Window
            +-- gtk.Dialog
              +-- gtk.MessageDialog

Properties

"message-type"Read-Write-ConstructThe type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR
"buttons"Write-ConstructThe buttons shown in the message dialog: gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL

Style Properties

"message-border"Read-WriteThe width of border around the label and image in the message dialog.

Attributes

"image"ReadThe stock ID image
"label"ReadThe label widget that contains the message text.

Description

The gtk.MessageDialog presents a dialog with an image representing the type of message (Error, Question, etc.) alongside some message text. It's simply a convenience widget; you could construct the equivalent of gtk.MessageDialog from gtk.Dialog without too much effort, but gtk.MessageDialog saves time.

The gtk.MessageDialog types are:

gtk.MESSAGE_INFOInformational message
gtk.MESSAGE_WARNINGNonfatal warning message
gtk.MESSAGE_QUESTIONQuestion requiring a choice
gtk.MESSAGE_ERRORFatal error message

A selection of predefined button sets is available for use in a message dialog:

gtk.BUTTONS_NONEno buttons at all
gtk.BUTTONS_OKan OK button
gtk.BUTTONS_CLOSEa Close button
gtk.BUTTONS_CANCELa Cancel button
gtk.BUTTONS_YES_NOYes and No buttons
gtk.BUTTONS_OK_CANCELOK and Cancel buttons

See the gtk.Dialog reference page for additional methods to be used with the gtk.MessageDialog.

Constructor

    gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_NONE, message_format=None)
parent :the transient parent, or None if none
flags :the dialog flags - a combination of: gtk.DIALOG_MODAL, gtk.DIALOG_DESTROY_WITH_PARENT or 0 for no flags
type :the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR.
buttons :the predefined set of buttons to use: gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL
message_format :a string containing the message text or None
Returns :a new gtk.MessageDialog widget

Creates a new gtk.MessageDialog, which is a simple dialog with an icon indicating the dialog type (error, warning, etc.) specified by type and some text (message_format) the user may want to see. parent if specified indicates the transient parent of the dialog. The flags allow the specification special dialog characteristics: make the dialog modal (gtk.DIALOG_MODAL) and destroy the dialog when the parent is destroyed (gtk.DIALOG_DESTROY_WITH_PARENT). When the user clicks a button a "response" signal is emitted with response IDs. buttons specifies the set of predefined buttons to use: gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL. See gtk.Dialog for more details.

Methods

gtk.MessageDialog.set_markup

    def set_markup(str)
str :a markup string (see the Pango markup language reference)

Note

This method is available in PyGTK 2.4 and above.

The set_markup() method sets the text of the message dialog to the contents of str. If str contains text marked up with the Pango text markup language it will be displayed with those attributes. Note the '<', '>' and '&' characters must be replaced with '&lt;', '&gt;' and '&amp;' respectively to be displayed literally.