• 1
  • 4
  • 5
  • 6(current)
  • 7
  • 8
  • 10
Python Inside
#76
ok , i parsed the playlist file, but how can i play all the files one after one.

this is the code, but it just plays the last file in the list

Quote:# loop until eof
for x in lines:
if x.find("#ext") == 0:
continue
print x
xbmc.mediaplay(x)

any sugestions how to program it
#77
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.
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.


Image
#78
Star 
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])
                 
#79
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
#80
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
#81
hi

does the pil library is planned to be added in your port darkie?
it's useful to process images.
more infos here : pil website

i don't know at all how python libraries are working, and also i have no ideas how to compile them for xbmc. so more infos about this process could help us all i guess.

thanks

alex
#82
another question:
i'm using the windowexample as source
i wanted to create a loop using a "while" but i'm not sure if i have to add the w.domodal() line in the loop or out of the loop. i tired both but it crashed...
#83
Quote:does the pil library is planned to be added in your port darkie?
maybe, but not at this time. problem is al those libraries take a lot of memory and python is already using to much

about the w.domodal().
if you leave it away, you will see that the python window doesn't stay onscreen because the python script just ends. using w.domodal() or an endless loop will let the script run forever. with the difference that

w.domodal() takes no processor speed and stops when w.close() is called.

an endless loop will take 100 % processor speed and only stops when you break out of the loop

and i'll try to upload new sources to cvs today which makes it possible to use xbmc playlists and add buttons to the window
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.


Image
#84
thank you very much darkie for your help!
also a special thank you for the support and the functions you still add to the sources.
#85
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
#86
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
#87
only fonts in cvs\skin\mediadir\fonts are supported
that is, font13, font14 and font64.
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.


Image
#88
(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!
#89
Sad 
hi.

is it possible to use the pysqlite library with the xbmc python impementation.

i've fiddeled around some and tried to get it to work with no luck at all, and i think the problem is that it can't load the _sqllite.pyd library, so the question is: can we load external python libraries into xbmc?
#90
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.
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.


Image
  • 1
  • 4
  • 5
  • 6(current)
  • 7
  • 8
  • 10

Logout Mark Read Team Forum Stats Members Help
Python Inside0