GTK: Using gtk.AboutDialog()

Here I will show how to use the about dialog, which is in my opinion not too well documented. In particular the activation of the close button was important for me (as a beginner in the python programming language).

Most people learn best from examples; so here is the one:

import gtk        

dlg = gtk.AboutDialog()
dlg.set_version("0.1")
dlg.set_name("Application")
# load GPL text file
try:
    h = open('GPL.txt','r')
    s = h.readlines()
except IOError, err:
    print "IO Error %s" % err
except:
    print "Unexpexted error"

    gpl = ""
    for line in s:
        gpl += line
    h.close()
    dlg.set_license(gpl)
    dlg.set_authors(["Your name here (programmer)"])
    dlg.set_website("http://www.yourSite.here")
    def close(w, res):
        if res == gtk.RESPONSE_CANCEL:
            w.hide()
    dlg.connect("response", close)
    dlg.show()
Author: Christoph Hermes, published: 2007-09-09 12:42:26