Chapter 65. About Dialog

An About Dialog is used to show information about the application. This often includes the name, version, website, license information, copyright string, authors, etc. Usually, About Dialogs can be accessed through the Help menu.

Constructor

aboutdialog = gtk.AboutDialog()

Methods

Once the About Dialog has been created, it will be empty with the exception of the name of the Python script. Now we can add a variety of information:

aboutdialog.set_name(name)
aboutdialog.set_version(version)
aboutdialog.set_copyright(copyright)
aboutdialog.set_comments(comment)
aboutdialog.set_website(website)
aboutdialog.set_website_label(label)
aboutdialog.set_authors([authors])
aboutdialog.set_documentors([documentors])
aboutdialog.set_artists([artists])
aboutdialog.set_logo(filepath)
aboutdialog.set_license(license)
aboutdialog.set_wrap_license(boolean)

Most of the options available are relatively self-explanatory. The set_comments() string is a simple message about what the application does. set_wrap_license() ensures that the license is displayed neatly in its dialog and in most cases would be set to True.

The .set_authors(), .set_documenters() and .set_artists() methods require a Python list. The list can contain one or more names which are separated by commas.

We then display the About Dialog with the method:

aboutdialog.run()

At this point, the About Dialog enters its own loop and waits for a response from the user. Immediately after issuing the aboutdialog.run() method, use:

aboutdialog.destroy()

One current problem with About Dialog windows is that they position themselves at the center of the screen, rather than at the center of the parent window (if you have one). This is beneficial in some cases, however can be annoying when using a non-maximized application. To position the About Dialog over the window use:

aboutdialog.set_transient_for(window)

Example

#!/usr/bin/env python

import gtk

class AboutDialog():
    def __init__(self):
        aboutdialog = gtk.AboutDialog()
        aboutdialog.set_name("PyGTK Tutorial")
        aboutdialog.set_version("0.00")
        aboutdialog.set_comments("New PyGTK Tutorial featuring updated widgets and methods")
        aboutdialog.set_website("http://www.learngtk.org/")
        aboutdialog.set_website_label("LearnGTK Website")
        aboutdialog.set_authors(["Andrew Steele"])

        aboutdialog.run()
        aboutdialog.destroy()

AboutDialog()

Download aboutdialog.py