Kodi Community Forum
Python Scripts Development - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Python Scripts Development (/showthread.php?tid=2045)

Pages: 1 2 3 4 5 6 7 8


- darkie - 2004-01-23

playing a file one after one is not possible atm. you would need access to the xbmc playlist from within python for that, which is not possible yet.


- XDX - 2004-01-25

thanks for the idea... i made a simple python script to download current weather conditions and display them on your screen.  the ui isn't great, but it works.
Quote:#display weather forecast on your xbox


########enter your zip code###########
zipcode = '94025'        


import sys, urllib, string, urlparse, re, xbmc, xbmcgui

#will parse out text between given tag
def parsexml( line, tag ):
   result= re.search('<' + tag + '>.*' + tag + '>', line, re.dotall)
   try:
       if result.group(0):
           mod = string.replace(result.group(0), '<' + tag + '>','')
           mod = string.replace(mod, '</' + tag + '>', '')
           mod = string.lstrip(mod)
           return mod
   except:
       return


url = 'http://www.rssweather.com/rss.php?config=&forecast=zandh&zipcode=' + zipcode + '&alt=rss20a'
data = urllib.urlopen(url)
currentline= data.read()
itemdivide= string.split(currentline, '<item>')
place= parsexml(itemdivide[0], 'title')

i=1
items= len(itemdivide)
dayforecast=[]
forecast=[]

while i < items:
   check=parsexml(itemdivide[i], 'category')
   if check=="current conditions":
       time=parsexml(itemdivide[i], 'pubdate')
       ctemp=parsexml(itemdivide[i], 'description')
   if check=="weather forecast":
       forecast.append(parsexml(itemdivide[i],'description'))
       dayforecast.append(parsexml(itemdivide[i], 'title'))
   i=i+1
   
# now we have all the parts we need so display to the user

dialog= xbmcgui.dialog()
dayforecast.insert(0, 'exit')
dayforecast.insert(0, 'current temperature: ' + ctemp)
dayforecast.insert(0, 'information from: ' + time)
selected= dialog.select(place, dayforecast)
if selected < 3:
   print 'quitting..'
else:
   dialog.ok(dayforecast[selected],forecast[selected-3])
                 



- san - 2004-01-25

there is something called superkaramba for unix flavored os-es. it allows tiny (scripted) programs make your desktop more beautifull by adding things like clocks, systeminfo and weatherinfo on your desktop.

i'm not a python guru but i use this "liquid weather ++" script for superkaramba on my freebsd machine and it works great. it displays the weather in you own location (it's configurable through a gui) and it lools very nice. i don't have the time or the python knowledge to pick this up but perhaps someone else will.

check this url for screenshots and the files:
http://www.kde-look.org/content/show.php?content=6384


- alx5962 - 2004-01-29

hi!
i tried to use the onaction def out of a class (as the only way to interact is using the pad) but it crashed xbmc.
so i'm not sure what's the problem and any help would be welcome.

thanks

alex


- alx5962 - 2004-02-02

here is the code for my meteo script for france. i dedicate it to darkie as he was a huge help for me Image

Quote:import sys, urllib, re, xbmcgui, xbmc, os

baseurl = 'http://www.lachainemeteo.com/imageslcm/frannebp'
baseurl2 = 'http://www.lachainemeteo.com/imageslcm/frantmpp'

dossier = 'q:\\'
action_show_info = 11
action_stop = 13
action_previous_menu = 10

nomfichier = ''

print 'demarrage'

class window(xbmcgui.window):

def (self):
self.straction = xbmcgui.controllabel(100, 100, 200, 200, '', 'font13')
self.addcontrol(self.straction)
global compteur
compteur = 0

def onaction(self, action):
#print('recieved action with number:' + str(action))

if action == action_show_info:
global compteur
if compteur == 0:
print 'ajout compteur 1'
self.chargement('meteoja',0,'pm')
compteur = 1
elif compteur == 1:
print 'ajout compteur 2'
self.chargement('meteojb',1,'am')
compteur = 2
elif compteur == 2:
print 'ajout compteur 2'
self.chargement('meteojc',1,'pm')
compteur = 3

if action == action_stop:
self.sortir()

if action == action_previous_menu:
self.sortir()

def chargement(self,nomfile,journee,periode):
#self.straction.settext('chargement')
nomfichier = nomfile +'1'
global url
url = baseurl + str(journee) + periode + '.jpg'
self.downloadurl(url,nomfichier)
global localfile
localfile = dossier + nomfichier + ".jpg"
self.addcontrol(xbmcgui.controlimage(30,120,320,300, localfile))
nomfichier2 = nomfile +'2'
global url2
url2 = baseurl2 + str(journee) + periode + '.jpg'
self.downloadurl(url2,nomfichier2)
global localfile2
localfile2 = dossier + nomfichier2 + ".jpg"
self.addcontrol(xbmcgui.controlimage(345,120,330,300, localfile2))
self.supfichier(localfile)
self.supfichier(localfile2)


def sortir(self):
self.straction.settext('au revoir')
self.close()

def downloadurl(self,fichier,nom):        
try:
loc = urllib.urlopener()
loc.retrieve(fichier, dossier + nom + ".jpg")
#print 'download ok'
#self.straction.settext('download ok')

except:
print 'erreur'
self.straction.settext('download failed')

def supfichier(self,fichier):
if os.path.isfile(fichier):
os.remove(fichier)
#print 'fichier sup'



########## main ##########
meteo = window()

c2 = xbmcgui.controllabel(300, 50, 200, 200, u'text', 'font14', '0xff0080c0')
c2.settext('prévisions météo')
meteo.addcontrol(c2)
c3 = xbmcgui.controllabel(260, 80, 200, 200, u'text', 'font14', '0xffff80c0')
c3.settext('offert par la chaine météo')
meteo.addcontrol(c3)
c4 = xbmcgui.controllabel(250, 440, 200, 200, u'text', 'font14')
c4.settext('touche blanche pour changer')
meteo.addcontrol(c4)
c5 = xbmcgui.controllabel(300, 480, 200, 200, u'text', 'font14')
c5.settext('back pour quitter')
meteo.addcontrol(c5)
c6 = xbmcgui.controllabel(260, 510, 200, 200, u'text', 'font14', '0xff666666')
c6.settext('code : [email="[email protected]"][email protected][/email]')
meteo.addcontrol(c6)

meteo.chargement('meteoj',0,'am')
meteo.domodal()
del meteo



- alx5962 - 2004-02-03

one more question darkie, i know i'm harrassing you :lol:
i just noticed only font13 and font14 works (i tried smaller ones but nothing on the screen then).
how can i use smaller fonts so?

thank you again !

alex


- darkie - 2004-02-03

only fonts in cvs\skin\mediadir\fonts are supported
that is, font13, font14 and font64.


- alx5962 - 2004-02-03

(darkie @ feb. 03 2004,20:08 Wrote:only fonts in cvs\skin\mediadir\fonts are supported
that is, font13, font14 and font64.
thank u for the reply darkie!


- darkie - 2004-02-08

you can't load external dll's (.pyd) yet. i'm busy with that atm.
only problem is that the dll has to be compiled for the xbox, and _sqllite.pyd is probably not.


- darkie - 2004-02-08

Quote:darkie are you interested to see the scripts written using your python port?
sure, if you upload them to www.xboxmediaplayer.it/upload i will add them into cvs. this is the only way, cause there isn't a webpage for python scripts yet.

Quote:is there a tutorial to compile our own pyd for the xbox? as i really wish to see the pil library ported to our nice console
first i need to create some working examples myself before i can create a tutorial Smile . another problem is that pil has to be ported to the xbox first (if it is needed) before you can create a pyd at all


- alx5962 - 2004-02-10

hi darkie!
i need your help again Huh

i'd like to create a 'pop-up' like window and being able to close it to easily. but i have no idea if we are able to do it using xbmc and also how to do it Sad

thank you again for your patience with me darkie Smile


- alx5962 - 2004-02-13

i guess you have no time to reply to my previous post darkie...

i just noticed settext has to be named setlabel in the new cvs compile. the buttons are a great feature so i really have to include them in thefuture.

if you want to see of one my scripts, check the french tv guide here:
tv guide france


- darkie - 2004-02-14

you can't create custom dialogs (if that is what you mean?)

what you can do is create a new window and close it after pressing "ok?". after pressing ok the window will be destroyed and you will automaticly return to the old window.

just tried your script, very nice.. to bad it is only useful for france Smile


- alx5962 - 2004-02-15

thank you darkie, without your help i wwould never have started to work on scripts and even learnt python in fact. so thank you again for all!
your idea about the dialog window is very nice, i was more on a new window idea but the dialog could fit well for my need

:d


- alx5962 - 2004-02-15

darkie, i just noticed sometimes when a python script crash, xbmc is totally frozen and so i need to restart the xbox.
is this a known bug?

and what do you think about adding a debug log for python? so it would be easier to know where is the problem when the script crashes the xbox.