def __init__(self, control, coords=(0, 0), anim=[], **kwargs): self.controlXML = control self.id = self.controlXML.getId() self.label = xbmc.getInfoLabel("Control.GetLabel(%i)" % self.id) self.anim = anim try: extra = dict([k.split("=") for k in self.label.split(",")]) except: extra = {} option = {} x, y, w, h = self.getCoords(coords) # ATTENTION: in Frodo from Oct. 26th 2012 type(self.controlXML) is always xbmcgui.Control!!! # Therefore the test for the ID of the control. if type(self.controlXML ) == xbmcgui.ControlImage or self.controlXML.getId() in [2001]: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlImage texture = self.label valideOption = "colorKey, aspectRatio, colorDiffuse".split(", ") for key, value in extra.items(): key, value = key.strip(), value.strip() if key == "texture": texture = value if key not in valideOption: continue option[key] = value if "color" in key.lower(): option[key] = '0x' + value elif key == "aspectRatio" and value.isdigit(): option[key] = int(value) texture = getTexture(texture) # ControlImage( x, y, width, height, filename[, colorKey, aspectRatio, colorDiffuse] ) self.control = xbmcgui.ControlImage(x, y, w, h, texture, **option) elif type(self.controlXML ) == xbmcgui.ControlLabel or self.controlXML.getId() in [ 1999, 2002, 2003, 2045 ]: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlLabel valideOption = "font, textColor, disabledColor, alignment, hasPath, angle".split( ", ") for key, value in extra.items(): key, value = key.strip(), value.strip() if key not in valideOption: continue option[key] = value if "color" in key.lower(): option[key] = '0x' + value elif key == "alignment": option[key] = self.getAlignment(value) elif key == "hasPath" and value == "true": option[key] = True elif key == "angle" and value.isdigit(): option[key] = int(value) # ControlLabel(x, y, width, height, label[, font, textColor, disabledColor, alignment, hasPath, angle]) self.control = xbmcgui.ControlLabel(x, y, w, h, "", **option) elif type(self.controlXML ) == xbmcgui.ControlProgress or self.controlXML.getId() in [ 2004, 2005 ]: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlProgress valideOption = "texturebg, textureleft, texturemid, textureright, textureoverlay".split( ", ") for key, value in kwargs.items(): key, value = key.strip(), value.strip() if key not in valideOption: continue option[key] = getTexture(value) # ControlProgress(x, y, width, height[, texturebg, textureleft, texturemid, textureright, textureoverlay]) self.control = xbmcgui.ControlProgress(x, y, w, h, **option) elif type(self.controlXML) in [ xbmcgui.ControlButton, xbmcgui.ControlRadioButton ] or self.controlXML.getId() == 2006: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlRadioButton # ControlRadioButton(x, y, width, height, label[, focusTexture, noFocusTexture, textOffsetX, textOffsetY, alignment, font, textColor, disabledColor, angle, shadowColor, focusedColor, TextureRadioFocus, TextureRadioNoFocus]) option = {"TextureRadioFocus": "", "TextureRadioNoFocus": ""} # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlButton # ControlButton(x, y, width, height, label[, focusTexture, noFocusTexture, textOffsetX, textOffsetY, alignment, font, textColor, disabledColor, angle, shadowColor, focusedColor]) valideOption = "focusTexture, noFocusTexture, textOffsetX, textOffsetY, alignment, font, textColor, disabledColor, angle, shadowColor, focusedColor, TextureRadioFocus, TextureRadioNoFocus".split( ", ") for key, value in extra.items(): key, value = key.strip(), value.strip() if key not in valideOption: continue option[key] = value if "color" in key.lower(): option[key] = '0x' + value elif key == "alignment": option[key] = self.getAlignment(value) elif key in "focusTexture,noFocusTexture,TextureRadioFocus,TextureRadioNoFocus".split( ","): option[key] = getTexture(value) elif key in "angle,textOffsetX,textOffsetY".split( ",") and value.isdigit(): option[key] = int(value) self.control = xbmcgui.ControlRadioButton(x, y, w, h, "", **option) # used for cancel scan ( iscanceled = self.control.isSelected() ) self.control.setSelected(False)
def __init__(self, control, ctype, coords=(0, 0), anim=[], **kwargs): self.SKINS_PATH = os.path.join(addonDir, "resources", "skins") self.ADDON_SKIN = ("default", XBMC_SKIN)[os.path.exists( os.path.join(self.SKINS_PATH, XBMC_SKIN))] self.MEDIA_PATH = os.path.join(self.SKINS_PATH, self.ADDON_SKIN, "media") self.controlXML = control # from self.getControl(2001) self.id = self.controlXML.getId() self.label = xbmc.getInfoLabel("Control.GetLabel(%i)" % self.id) self.anim = anim try: extra = dict([k.split("=") for k in self.label.split(",")]) except: extra = {} option = {} x, y, w, h = self.getCoords(coords) # HERE! print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA self.controlXML: " + repr( type(self.controlXML)) print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA self.controlXML: " + repr( self.controlXML) print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA xbmcgui.ControlImage: " + repr( xbmcgui.ControlImage) print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA xbmcgui.ControlLabel: " + repr( xbmcgui.ControlLabel) print "BLAAAAAAAAAAAAAAAAAAAAAAAAAAA xbmcgui.ControlProgress: " + repr( xbmcgui.ControlProgress) if type(self.controlXML) == xbmcgui.ControlImage or ctype == 0: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlImage texture = self.label valideOption = "colorKey, aspectRatio, colorDiffuse".split(", ") for key, value in extra.items(): key, value = key.strip(), value.strip() if key == "texture": texture = value if key not in valideOption: continue option[key] = value if "color" in key.lower(): option[key] = '0x' + value elif key == "aspectRatio" and value.isdigit(): option[key] = int(value) texture = self.getTexture(texture) # ControlImage(x, y, width, height, filename[, colorKey, aspectRatio, colorDiffuse]) self.control = xbmcgui.ControlImage(x, y, w, h, texture, **option) elif type(self.controlXML) == xbmcgui.ControlLabel or ctype == 1: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlLabel valideOption = "font, textColor, disabledColor, alignment, hasPath, angle".split( ", ") for key, value in extra.items(): key, value = key.strip(), value.strip() if key not in valideOption: continue option[key] = value if "color" in key.lower(): option[key] = '0x' + value elif key == "alignment": option[key] = self.getAlignment(value) elif key == "hasPath" and value == "true": option[key] = True elif key == "angle" and value.isdigit(): option[key] = int(value) # ControlLabel(x, y, width, height, label[, font, textColor, disabledColor, alignment, hasPath, angle]) self.control = xbmcgui.ControlLabel(x, y, w, h, "", **option) elif type(self.controlXML) == xbmcgui.ControlProgress or ctype == 2: # http://passion-xbmc.org/gros_fichiers/XBMC%20Python%20Doc/xbmc_svn/xbmcgui.html#ControlProgress valideOption = "texturebg, textureleft, texturemid, textureright, textureoverlay".split( ", ") for key, value in kwargs.items(): key, value = key.strip(), value.strip() if key not in valideOption: continue option[key] = self.getTexture(value) # ControlProgress(x, y, width, height[, texturebg, textureleft, texturemid, textureright, textureoverlay]) self.control = xbmcgui.ControlProgress(x, y, w, h, **option) else: print "ERROR TRACEBACK BLAA. no match for self.controlXML: " + repr( self.controlXML)