Gtk About Dialog
Posted on November 1, 2007
Filed Under gtk, python |
The example that follow show a gtk about dialog with a working close button and a working external link button. We will obtain something like this:
We will put focus on how to obtain a response when we click on the link. The funcion that do the trick is gtk.about_dialog_set_url_hook that set a callback that will be called on the click action.
Python code
-
-
import gtk
-
import subprocess
-
-
def on_url(d, link, data):
-
subprocess.Popen(["firefox", "http://ferama.netsons.org"])
-
-
gtk.about_dialog_set_url_hook(on_url, None)
-
-
def create_dialog():
-
dlg = gtk.AboutDialog()
-
dlg.set_version("0.1")
-
dlg.set_name("app")
-
dlg.set_license("This code is free")
-
dlg.set_authors(["Marco Ferragina"])
-
dlg.set_website("http://ferama.netsons.org")
-
def close(w, res):
-
if res == gtk.RESPONSE_CANCEL:
-
w.hide()
-
dlg.connect("response", close)
-
return dlg
-
-
if __name__ == "__main__":
-
dlg = create_dialog()
-
dlg.run()
Comments
One Response to “Gtk About Dialog”
Leave a Reply

Thanks for this example, I made this a little more generic in my code:
Class AboutSetup():
def __init__(self):
gc = gconf.client_get_default()
browser = gc.get_string(’/desktop/gnome/url-handlers/http/command’)
email = gc.get_string(’/desktop/gnome/url-handlers/mailto/command’)
gtk.about_dialog_set_url_hook( self._link_handle_cb, browser)
gtk.about_dialog_set_email_hook( self._link_handle_cb, email)
def _link_handle_cb( self, win, link, data):
cmd = data % (link,)
subprocess.Popen( cmd.split() )