All pastes #13592 Raw Edit

Untitled

public text v1 · immutable
#13592 ·published 2005-06-06 19:18 UTC
rendered paste body
#"^(http|ftp|file)://"

import urllib
import base64
import gtk
import gobject

url = 'http://rafb.net/paste/results/n0r11630.txt'
fd = urllib.urlopen(url)

img_encoded = base64.b64encode(fd.read())
img_decoded = base64.b64decode(img_encoded)

print img_decoded

box = gtk.VBox()
image = gtk.Image()
try:
    pixbufloader = gtk.gdk.PixbufLoader()
    pixbufloader.write(img_decoded)
    pixbufloader.close()
    pixbuf = pixbufloader.get_pixbuf()
    image.set_from_pixbuf(pixbuf)
    box.pack_end(image)
except gobject.GError:
    print 'it is uri'
    #try following and reading as in line 8

win = gtk.Window()
win.add(box)

win.show_all()
gtk.main()