# MessageDialog (Python)

Marta Maria Casetti
mmcasetti@gmail.com 2012
A message window

# MessageDialog

A message dialog which prints messages on the terminal, depending on your choices.

# Code used to generate this example

# Useful methods for a MessageDialog widget

In line 18 the signal `"activate"` is connected to the callback function `message_cb()` using `widget.connect(signal, callback function)`. See for a more detailed explanation.

In the constructor of MessageDialog we could set flags as `Gtk.DialogFlags.DESTROY_WITH_PARENT` (to destroy the messagedialog window when its parent window is destroyed) or as `Gtk.DialogFlags.MODAL` (no interaction with other windows of the application).

In the constructor of MessageDialog we could set type as any of `Gtk.MessageType.INFO, Gtk.MessageType.WARNING, Gtk.MessageType.QUESTION, Gtk.MessageType.ERROR, Gtk.MessageType.OTHER` depending on what type of message we want.

In the constructor of MessageDialog we could set buttons as any of `Gtk.ButtonsType.NONE, Gtk.ButtonsType.OK, Gtk.ButtonsType.CLOSE, Gtk.ButtonsType.CANCEL, Gtk.ButtonsType.YES_NO, Gtk.ButtonsType.OK_CANCEL`, or any button using `add_button()` as in Gtk.Dialog.

We could substitute the default image of the MessageDialog with another image using

image = Gtk.Image() image.set_from_stock(Gtk.STOCK_CAPS_LOCK_WARNING, Gtk.IconSize.DIALOG) image.show() messagedialog.set_image(image)

where `Gtk.STOCK_CAPS_LOCK_WARNING` is any image from Stock Items. We could also set any image as in the Image widget, as `image.set_from_file("filename.png")`.

`format_secondary_text("some secondary message")` sets a secondary message. The primary text becomes bold.

# API References

In this sample we used the following:

GtkMessageDialog

GtkDialog

GtkWindow

GSimpleAction

GActionMap

GMenu

GtkApplication