Non-blocking addon
#1
Hello,
I am writing add-on that reads data from file and displays it on home screen. For now, I am using dummy variable i instead of file.
Problem is that when I run this script, XBMC freezes. Tried with threading, but with no success. I am planning to do car pc, and this add on should display outside temp. and average fuel consumption.
Code:
import xbmcgui, xbmc, time
window = xbmcgui.Window(10000)
i = 0
while True:
    i += 1
    pod = xbmcgui.ControlLabel(window.getWidth() /2 - 130*2, 50, 130, 50, str(i), font='font24_title', textColor='0xFFFFFFFF')
    window.addControl(pod)
    time.sleep(1000)
    window.removeControl(pod)

Thank you,
Nikola
Reply
#2
Add the control once, and then update the label.

Code:
import xbmcgui, xbmc

window = xbmcgui.Window(10000)
pod = xbmcgui.ControlLabel(window.getWidth() /2 - 130*2, 50, 130, 50, str(i), font='font24_title', textColor='0xFFFFFFFF')
window.addControl(pod)

i = 0

while True:
    pod.setLabel(str(i))
    i += 1
    xbmc.sleep(1000)

window.removeControl(pod)

You also don't need time if you have xbmc.
Reply
#3
Thank you,
works better, but after some time it stops working. Is there any other way to display info on main screen?
I tried to make it into a service, but then it doesn't work at all.
Reply
#4
Dont know if this is the best way to display the info or not. Ideally this sort of thing would be handled by the skin, but that is a huge amount of work for such a small bit of functionality.

Is it disappearing after the screensaver becomes active?

Post your code in github or something. Setting up services can be a little tricky.

Here is a service that I created but never distributed that checked for updates for RaspBMC and posted an image to the Home screen when one was available. There might be something useful in there for you: https://github.com/KODeKarnage/service.r...tification
Reply
#5
Thanks for help.
I managed to solve this problem. Service is now working (problem was in one misspelled letter in extension point Sad ).
I modified code to send data to skin, which will handle labels. For now, I am displaying just counter instead time on system time label.
Here is the code of service:
Code:
import xbmc
i = 0
while not xbmc.abortRequested:
    xbmc.executebuiltin("Skin.SetString(proba," +str(i) + ")")
    xbmc.sleep(2500)
    i += 1
And i have to modify one line of includes.xml from:
PHP Code:
<label>$INFO[System.Time]</label
to
PHP Code:
<label>$INFO[Skin.String(proba)]</label
Reply

Logout Mark Read Team Forum Stats Members Help
Non-blocking addon0