OK
Rating:
0.00
Thread Listing » General AWN Discussion
raw image data -> gtk.Image?
#22881 by c.atterly (0.9959) posted on 7:36am Friday, June 27th, 2008
Hello! For the weather applet, the map currently is downloaded to a file in /tmp and then loaded in the dialog. However, the dialog is created right after each file is downloaded, so it isn't really necessary. What would be better would be to send the data right to the dialog.
[Q]



So currently it basically does:
[Q]



 


urllib.urlretrieve(imgSrc, "/tmp/awnWeatherMap")
map = gtk.Image()
map.set_from_file("/tmp/awnWeatherMap")
[Q]
 



But what I would rather do is something like:
[Q]



 


rawImgData = urllib.urlopen(imgSrc).read()
map = gtk.Image()
#some magical call to set the map from rawImgData
[Q]
 




but I don't know how to create a gtk.Image from the CONTENTS of a file instead of a file path. I am looking at the gtk.Image docs and see lots of set_from_xxx, but nothing that seems to allow this. Any ideas?
[Q]



--
-Chaz
Score: 0 points
Any particular reason?
#22884 by sharkbait (0.9200) posted on 8:55am Friday, June 27th, 2008
Try using PixbufLoader. Something like this should work:
[Q]



 

rawImg = urllib.urlopen(imgSrc)
pixbufLoader = gtk.gdk.PixbufLoader()
pixbufLoader.write(rawImg.read())
map = gtk.image_new_from_pixbuf(pixbufloader.get_pixbuf())
[Q]
 
Score: 0 points
Any particular reason?
#22885 by c.atterly (0.9959) posted on 9:11am Friday, June 27th, 2008
sharkbait said:
Try using PixbufLoader. Something like this should work:
[Q]



Thanks and double thanks! This worked perfectly, AND I had no idea I could create images in one step with the gtk.image_new_from_xxx, instead of creating the image and then using set_from_xxx.
[Q]

--
-Chaz
Score: 0 points
Any particular reason?
#27156 by liliwang (0.2020) posted on 12:02am Friday, January 13th, 2012
( no avatar )
Bijoux Tiffany brille si elle est effectivement nettoyés et les gens ont des trésors de Tiffany colliers polished.Tiffany à la propriété dans le type de diamants, d'émeraudes et de saphirs. Ce sont généralement en or, argent ou platine Tiffany vente. Certains de ces bijoux sont des antiquités qui ont été transmis par les ancêtres d'une époque particulière à la suivante.Tiffany bijoux peut perdre son éclat si elle n'est pas correctement pris en charge avec un nettoyeur de bijoux Tiffany bon. Absolument tout le monde des bijoux Tiffany rabais avec quelques Montre Rolex à défendre doit découvrir plus sur les nettoyeurs d'oreilles Tiffany qui sont facilement disponibles afin qu'ils ne causent pas de mal d'éléments bénéfiques.
[Q]

Score: 0 points
Any particular reason?
Thread Listing » General AWN Discussion » raw image data -> gtk.Image?

Post A Reply:

Powered by Metaforum ©2004-2012
Get your own Free AJAX Forum Messageboard by visiting the offical site.
.