Retrieve & Display Image
#1
how can i make this script display the image it downloads:

Quote:import xbmc, xbmcgui, urllib

#get actioncodes from keymap.xml
action_previous_menu = 10
action_select_item = 7

class myclass(xbmcgui.window):
def (self):
self.stractioninfo = xbmcgui.controllabel(100, 120, 200, 200, '', 'font13', '0xffff00ff')
self.addcontrol(self.stractioninfo)
self.stractioninfo.setlabel('push back to quit - a to download')

def onaction(self, action):
if action == action_previous_menu:
self.close()
if action == action_select_item:
webfile = 'http://www3.kgan.com/program/wxinfo/wsiftp/kgan_4wpnet.jpg'
localfile = 'q:\\scripts\\weather\\kgan7day.jpg'
self.downloadurl(webfile,localfile)

def downloadurl(self,source, destination):        
try:
loc = urllib.urlopener()
loc.retrieve(source, destination)
self.message('download ok')
except:
self.message('download failed')

def message(self, message):
dialog = xbmcgui.dialog()
dialog.ok(" my message title", message)

mydisplay = myclass()
mydisplay .domodal()
del mydisplay

hurtz
Reply
#2
you need to add a control to display the image.

Quote:self.addcontrol(xbmcgui.controlimage(x1,y1,x2,y2, image))

(x1,y1) , (x2,y2) are the corners of the screen that define the area that the image will be drawn onto.

in your example, replace

Quote:self.message('download ok')

with

Quote:self.addcontrol(xbmcgui.controlimage(0,0,self.getwidth(),self.getheight(), 'q:\\scripts\\logo.gif'))

this will fill the entire screen with your image.  note, the image may be stretched to fill the area.

and you'll still need to hit "a" to force the download when the script first runs. (you can automate it by moving the download code out of the onaction and into the "self" window.)

oh yeah, i forgot to tell you, i tried to view a few animated gifs using "my pictures" and they definately dont show the animation, but just the first frame.   i'm not sure if this control will show the animation either.  you should pm darkie if it doesnt work.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#3
(kraqh3d @ june 17 2004,19:07 Wrote:oh yeah, i forgot to tell you, i tried to view a few animated gifs using "my pictures" and they definately dont show the animation, but just the first frame.   i'm not sure if this control will show the animation either.  you should pm darkie if it doesnt work.
i think animated gif's only work in skin, not in xbmc's image viewer("my pictures"), but i'm not 100% sure, can someone confirm?
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#4
thanks for the help. i'd love to have animated .gif support. in fact, when i change this script to retrieve and display the .gif, it just hangs. kgan local radar

this is what i did. my local tv station has more accurate weather information than weather.com, so i wanted to display the 7 day forecast and if animated .gif support gets fixed / added, i'll have my local radar too. here are a couple of pics:


Image

Image

pretty cool stuff.

thanks again for the help guys.

hurtz
Reply
#5
i'm working on radar, too, though mine depends on pil getting added, rather than animated gifs. we'll see who gets it working first. :-) it would be awesome if you could just download and draw a single image file....

(i'm downloading a series of images from noaa and animating them within the script. which is, obviously, a lot more work.)
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#6
yes, mine is more of a hack. noaa would be awesome - then everyone could enjoy local radar based on zipcode or something. i've read your posts before and looked into what it would take to do something similar, but being a python newbie its not something i'm able to do yet.

whats the status on getting pil support?

does noaa have a weather warning system that could be put into an rss feed? we could turn the weather page into a complete weather monitoring system!

ooh - how about when a weather alert comes in, take the volume of the currently playing file and reduce it by 50%, then play the beep-beep-beep and scroll the alert. ok i'm getting carried away now.

hurtz
Reply
#7
hurtz, did you alter the script to get another gif file to test the script with a non-animated gif?  i'll play around with it this weekend.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#8
yeah, somethings not right. i tried with several animated gifs and they dont work. what's odd is that they arent even downloaded.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#9
hurtz,
i've actually considered doing all those things. i was listening to a storm warning on the weather channel this weekend (visiting someone else's house--i don't actually sit and watch the weather channel...) and even started thinking about trying to get that voice to read out the warnings.

i definitely intend to have it scroll local weather warnings. it's all a matter of parsing web data, because noaa makes this stuff very available.

unfortunately, i've read elsewhere on this forum that we can't overlay python output on top of xbmc output. which sucks, because if we could, it wouldn't be hard to have storm warnings scroll over your now playings and, when you saw that it was for your neighborhood, you could switch over to the radar program....

yeah, yeah, i'm a little carried away, too, but i'm from oklahoma. we take this stuff seriously. :-)

i'm writing a pc app to get everything downloading and displaying properly, which i'll port to the xbox if and when they add pil support (or if and when i try to build a gif decoder myself, but that looks like a nightmare!Wink.

as for when pil will be in xbmc, i've no idea. it won't be until after the next release, though, because they've got a feature freeze on. and, even then, i don't know how high a priority it'll be.

anyway, the pc app is already working. it's pretty cool. i run it at work in the background, just to make sure it keeps updating properly. i've got it checking for new images every minute (noaa only updates every six minutes or so, but it's irregular), and scrolling the 10 most recent (which is what you'd get if you went to their website). all 'round, it's a pretty cool little gadget. can't wait to get it on the xbox. :-)
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply

Logout Mark Read Team Forum Stats Members Help
Retrieve & Display Image0