[pygtk] Python code works in terminal but not with shortcut on the gnome panal

Felix Rabe (public) public at felixrabe.textdriven.com
Fri Mar 30 05:44:24 WST 2007


> try:
>    url_content = urllib.urlopen('http://www.google.com')
>    main_window.add(gtk.Label(url_content.read()))
> except IOError:
>    main_window.add(gtk.Label('             Error            '))

You should be able to debug the code yourself to find out what's going on:

First, omit the whole try:... except... clause from your code.  If that 
"helped", go on by adding a general except: clause with a label that 
tells you that an unexpected exception happened.  Then go on in that 
fashion and you should be able to find your way.

Wikipedia has an article on debugging, I'm giving you the direct link to 
your step: http://en.wikipedia.org/wiki/Debugging#Isolate_source_of_bug

I hope you find the bug.  If you do, tell me (no need to reply to the 
list then) what caused it, I'm curious about this one :o)

- Felix


More information about the pygtk mailing list