On 9/14/05, Nigel Tao <[EMAIL PROTECTED]> wrote: > On Wed, 2005-09-14 at 12:21 -0400, Mystilleef wrote: > > ===================================================== > > > > import gtk > > from gnome import url_show > > > > gtk.about_dialog_set_url_hook(url_show, "http://www.google.com") > > > > def create_about_dialog(): > > > > dialog = gtk.AboutDialog() > > dialog.set_website_label("http://www.google.com") > > dialog.show_all() > > > > return dialog > > > > ===================================================== > > > > When I click on the link on the dialog, I get the following > > error: > > > > TypeError: url_show() takes exactly 1 argument (3 given) > > > > > > As you can see, I have passed exactly one argument to > > url_show. What am I doing wrong? > > url_show takes 1 argument, but the callback from > about_dialog_set_url_hook should take 3. Thus, 3 args are being fed to > url_hook, which only takes one. Thus, your error message. > > Working version: > ===================================================== > #!/usr/bin/env python > > import gtk > from gnome import url_show > > dialog = gtk.AboutDialog() > > def foo(dialog, arg2, arg3): > print dialog > print arg2 > print arg3 > #url_show(arg2) > > gtk.about_dialog_set_url_hook(foo, "arg3") > dialog.set_website("arg2") > dialog.set_website_label("http://www.google.com") > dialog.show_all() > > gtk.main() > ===================================================== > > Or, since arg3 is optional, you can do something like > ===================================================== > gtk.about_dialog_set_url_hook(lambda dialog, url: url_show(url)) > dialog.set_website("http://www.google.com") > dialog.set_website_label("http://www.google.com") > ===================================================== > > > Nigel.
Thank you Nigel, that worked. Thanks _______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
