Change control in home page
#1
Hi guys,
I'm new on kodi add-on development, so i don't complete understand the system behind kodi!

My question is: I can change a control (ie: an image control) from a python script in the home page?
I have a skin for a carpc project and i would change an image control that display the amount of battery charge (with the serial port that communicate with an arduino board). If the battery is at x percentage the image is xxx, else the image is yyy. This image (that i've created and insert on the skin) is at the top of home page near the clock.

How i can change the control with python?
I've tried to wrote many codes but without successfull Sad

Thanks guys! Blush
Reply
#2
I have successfully change an image control on home page with a python addon.
The problem is that the control change but a new window is created from code

Code:
import xbmcaddon
import xbmcgui

C_BAT1 = 2001
C_BAT2 = 2002
C_BAT3 = 2003
C_BAT4 = 2004
C_BAT_CH = 2005

class myClass(xbmcgui.Window):
    def __init__(self):
        window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
        self.batt1 = window.getControl(C_BAT1)
        self.batt2 = window.getControl(C_BAT2)
        self.batt3 = window.getControl(C_BAT3)
        self.batt4 = window.getControl(C_BAT4)
        self.batt_ch = window.getControl(C_BAT_CH)
        self.batt1.setVisible(False)
        self.batt2.setVisible(True)
        
# We need to link the class to an object, and doModal to display it.
My_Window = myClass()
My_Window.doModal()
del My_Window

This code at init change the control but immediately create a new black window. If i remove doModal() function control doesn't change and new window isn't create.

Any solution to remove/don't create the new window? Thanks guy
Reply
#3
I guess you get it wrong. I'm not sure if you can access existing control IDs in a skin layout (I've never used XML-based skins in my project) but xbmcgui.Window() allows you to attach an xbmcgui.Control instance to an existing window, and then you can change this Control's contents. From what I understand, you need xmbcgui.ControlImage class.
Reply

Logout Mark Read Team Forum Stats Members Help
Change control in home page0