def __init__( self, *args, **kwargs): self.getTitle = kwargs.get('title') self.getPlot = kwargs.get('plot') self.getInfo = kwargs.get('info') self.getThumbnail = kwargs.get('thumbnail') self.getFanart = kwargs.get('fanart') self.getQuit = kwargs.get('quit') self.background = xbmcgui.ControlImage( 70, 20, 1150, 630, 'http://s6.postimg.org/58jknrvtd/backgroundventana5.png') self.title = xbmcgui.ControlTextBox(140, 60, 1130, 50) self.quit = xbmcgui.ControlTextBox(145, 90, 1030, 45) self.plot = xbmcgui.ControlTextBox( 120, 150, 1056, 140 ) self.info = xbmcgui.ControlFadeLabel(120, 310, 1056, 100) self.thumbnail = xbmcgui.ControlImage( 813, 43, 390, 100, self.getThumbnail ) self.fanart = xbmcgui.ControlImage( 120, 365, 1060, 250, self.getFanart ) self.addControl(self.background) self.addControl(self.title) self.addControl(self.quit) self.addControl(self.plot) self.addControl(self.thumbnail) self.addControl(self.fanart) self.addControl(self.info) self.title.setText( self.getTitle ) self.quit.setText( self.getQuit ) try: self.plot.autoScroll(7000,6000,30000) except: print "Actualice a la ultima version de kodi para mejor info" import xbmc xbmc.executebuiltin('Notification(bbcode_kodi2html([COLOR red][B]Actualiza Kodi a su última versión[/B][/COLOR]), bbcode_kodi2html([COLOR skyblue]para mejor info[/COLOR]),8000,"https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/kodi-icon.png")') self.plot.setText( self.getPlot ) self.info.addLabel(self.getInfo)
def __init__( self, *args, **kwargs): self.getTitle = kwargs.get('title') self.getPlot = kwargs.get('plot') self.getInfo = kwargs.get('info') self.getThumbnail = kwargs.get('thumbnail') self.getFanart = kwargs.get('fanart') self.background = xbmcgui.ControlImage( 70, 20, 1150, 630, 'http://s6.postimg.org/58jknrvtd/backgroundventana5.png') self.title = xbmcgui.ControlTextBox(140, 60, 1130, 50) self.plot = xbmcgui.ControlTextBox( 120, 150, 1056, 140 ) self.info = xbmcgui.ControlFadeLabel(120, 310, 1056, 100) self.thumbnail = xbmcgui.ControlImage( 813, 43, 390, 100, self.getThumbnail ) self.fanart = xbmcgui.ControlImage( 120, 365, 1060, 250, self.getFanart ) self.addControl(self.background) self.addControl(self.title) self.addControl(self.plot) self.addControl(self.thumbnail) self.addControl(self.fanart) self.addControl(self.info) self.title.setText( self.getTitle ) self.plot.autoScroll(7000,6000,30000) self.plot.setText( self.getPlot ) self.info.addLabel(self.getInfo)
def __init__(self): self.strActionInfo = xbmcgui.ControlLabel(100, 120, 200, 200, '', 'font13', '0xFFFF00FF') self.addControl(self.strActionInfo) self.strActionInfo.setLabel('Push BACK to quit - A to reset text') self.strActionFade = xbmcgui.ControlFadeLabel(100, 300, 500, 200, 'font13', '0xFFFFFF00') self.addControl(self.strActionFade) self.strActionFade.addLabel(str(getlightvals())) self.serport = serial.Serial('COM7', '57600', timeout=2)
def __init__(self): self.strActionInfoBox = xbmcgui.ControlTextBox(300, 120, 600, 600, 'font13', '0xFFFFFFFA') self.addControl(self.strActionInfoBox) self.strActionInfoBox.setText(txt) self.strActionInfo = xbmcgui.ControlLabel(300, 500, 400, 200, '', 'font13', '0xFFAFAFAF') self.addControl(self.strActionInfo) self.strActionInfo.setLabel('zurueck (ESC)') self.strActionFade = xbmcgui.ControlFadeLabel(350, 50, 200, 200, 'font18', '0xFFAFAFAF') self.addControl(self.strActionFade) self.strActionFade.addLabel('Beschreibung')
def __init__(self, *args, **kwargs): logger.debug() #### Compatibilidad con Kodi 18 #### if config.get_platform(True)['num_version'] < 18: if xbmcgui.__version__ == "1.2": self.setCoordinateResolution(1) else: self.setCoordinateResolution(5) self.show = kwargs.get("show") self.channel = kwargs.get("channel") self.data = kwargs.get("data") self.init = True self.mediapath = os.path.join(config.get_runtime_path(), 'resources', 'skins', 'Default', 'media') self.font = "font12" window_bg = xbmcgui.ControlImage(320, 130, 600, 440, os.path.join(self.mediapath, 'Windows', 'DialogBack.png')) self.addControl(window_bg) header_bg = xbmcgui.ControlImage(window_bg.getX(), window_bg.getY() + 8, window_bg.getWidth(), 35, os.path.join(self.mediapath, 'Windows', 'dialogheader.png')) self.addControl(header_bg) btn_close_w = 64 self.btn_close = xbmcgui.ControlButton(window_bg.getX() + window_bg.getWidth() - btn_close_w - 13, header_bg.getY() + 6, btn_close_w, 30, '', focusTexture=os.path.join(self.mediapath, 'Controls', 'DialogCloseButton-focus.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'DialogCloseButton.png')) self.addControl(self.btn_close) header_title_x = window_bg.getX() + 20 header_title = xbmcgui.ControlFadeLabel(header_title_x, header_bg.getY() + 5, self.btn_close.getX() - header_title_x, 30, font="font12_title", textColor="0xFFFFA500", _alignment=ALIGN_CENTER) self.addControl(header_title) header_title.addLabel(self.show) self.controls_bg = xbmcgui.ControlImage(window_bg.getX() + 20, header_bg.getY() + header_bg.getHeight() + 6, 562, 260, os.path.join(self.mediapath, 'Windows', 'BackControls.png')) self.addControl(self.controls_bg) self.scroll_bg = xbmcgui.ControlImage(window_bg.getX() + window_bg.getWidth() - 25, self.controls_bg.getY(), 10, self.controls_bg.getHeight(), os.path.join(self.mediapath, 'Controls', 'ScrollBack.png')) self.addControl(self.scroll_bg) self.scroll_bg.setVisible(False) self.scroll2_bg = xbmcgui.ControlImage(window_bg.getX() + window_bg.getWidth() - 25, self.controls_bg.getY(), 10, self.controls_bg.getHeight(), os.path.join(self.mediapath, 'Controls', 'ScrollBar.png')) self.addControl(self.scroll2_bg) self.scroll2_bg.setVisible(False) btn_add_season = xbmcgui.ControlButton(window_bg.getX() + 20, self.controls_bg.getY() + self.controls_bg.getHeight() + 14, 165, 30, 'Añadir Temporada', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(btn_add_season) self.btn_info = xbmcgui.ControlButton(window_bg.getX() + 210, btn_add_season.getY(), 120, 30, 'Información', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(self.btn_info) check_update_internet_w = 235 # Versiones antiguas no admite algunas texturas if xbmcgui.__version__ in ["1.2", "2.0"]: self.check_update_internet = xbmcgui.ControlRadioButton( window_bg.getX() + window_bg.getWidth() - check_update_internet_w - 20, btn_add_season.getY() - 3, check_update_internet_w, 34, "Actualizar desde Internet:", font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png')) else: self.check_update_internet = xbmcgui.ControlRadioButton( window_bg.getX() + window_bg.getWidth() - check_update_internet_w - 20, btn_add_season.getY() - 3, check_update_internet_w, 34, "Actualizar desde Internet:", font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png'), focusOnTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-focus.png'), noFocusOnTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-focus.png'), focusOffTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-nofocus.png'), noFocusOffTexture=os.path.join(self.mediapath, 'Controls', 'radiobutton-nofocus.png')) self.addControl(self.check_update_internet) self.check_update_internet.setEnabled(False) hb_bg = xbmcgui.ControlImage(window_bg.getX() + 20, btn_add_season.getY() + btn_add_season.getHeight() + 13, window_bg.getWidth() - 40, 2, os.path.join(self.mediapath, 'Controls', 'ScrollBack.png')) self.addControl(hb_bg) self.btn_ok = xbmcgui.ControlButton(window_bg.getX() + 68, hb_bg.getY() + hb_bg.getHeight() + 13, 120, 30, 'OK', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(self.btn_ok) self.btn_cancel = xbmcgui.ControlButton(self.btn_info.getX() + 30, self.btn_ok.getY(), 120, 30, 'Cancelar', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(self.btn_cancel) self.btn_delete = xbmcgui.ControlButton(self.btn_cancel.getX() + self.btn_cancel.getWidth() + 50, self.btn_ok.getY(), 120, 30, 'Borrar', font=self.font, focusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKey.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'KeyboardKeyNF.png'), alignment=ALIGN_CENTER) self.addControl(self.btn_delete) self.controls = [] self.onInit() self.setFocus(self.controls[0].edit_season) self.doModal()
def createPreview(self, fav): imgW = 256 imgH = 150 # collect all controls and add them in one call to save time allControls = [] # create preview images first so they are behind highlight image images = [] for nr in range(0, 16): pos = self.getControlPos(nr) image = xbmcgui.ControlImage(pos['x'], pos['y'] + 1, imgW - 2, imgH, '') allControls.append(image) images.append(image) self.highlightImage = xbmcgui.ControlImage(0, 0, imgW, 178, '') allControls.append(self.highlightImage) self.highLabel = '' #add a scroll label for highlighted item self.scrollLabel = xbmcgui.ControlFadeLabel(0, 0, 240, 30, 'font13', '0xFF000000') allControls.append(self.scrollLabel) #preloadImage is buffer for image update self.preloadImage = xbmcgui.ControlImage(0, -200, 256, 150, '') allControls.append(self.preloadImage) for nr in range(0, 16): pos = self.getControlPos(nr) logo = xbmcgui.ControlImage(pos['x'] + 5, pos['y'] + 100, 84, 48, '') label = xbmcgui.ControlLabel(pos['x'] + 6, pos['y'] + imgH - 1, 250, 30, 'font13') channelNr = xbmcgui.ControlLabel(pos['x'] + 200, pos['y'] + 5, 50, 20, 'font13', alignment=1) allControls.append(logo) allControls.append(label) allControls.append(channelNr) self.controls.append({ 'image': images[nr], 'logo': logo, 'label': label, 'channelNr': channelNr, 'program': '', 'visible': True }) addonPath = xbmcaddon.Addon().getAddonInfo('path') #add info controls posX = 768 #bg = xbmcgui.ControlImage(posX-10, -10, 530, 376, 'recentaddedback.png') #bg = xbmcgui.ControlImage(posX, 0, 512, 360, 'ContentPanel.png') #bg = xbmcgui.ControlImage(posX, 0, 512, 360, 'episodematte.png', colorDiffuse='0xFF333333') bg = xbmcgui.ControlImage( posX, 0, 512, 360, addonPath + '/resources/media/previewInfo.png') self.infoLogo = xbmcgui.ControlImage( 74 + posX, 5, 140, 70, (xbmcaddon.Addon().getAddonInfo('path') + '/resources/media/channel-highlight.png')) self.infoChannelTitle = xbmcgui.ControlLabel(0 + posX, 85, 287, 30, 'TITLE', alignment=2) self.infoImg = xbmcgui.ControlImage( 284 + posX, 3, 225, 146, (xbmcaddon.Addon().getAddonInfo('path') + '/resources/media/channel-highlight.png')) self.infoTitle = xbmcgui.ControlFadeLabel(5 + posX, 150, 500, 20, 'font16', '0xFFFFFFFF', 2) self.infoDesc = xbmcgui.ControlFadeLabel(5 + posX, 180, 500, 20, 'font13', '0xFFFFFFFF', 2) self.infoPlot = xbmcgui.ControlTextBox(8 + posX, 205, 500, 128, 'font13') self.infoNext = xbmcgui.ControlFadeLabel(8 + posX, 333, 500, 128, 'font12', '0xFFFFFFFF', 2) allControls.append(bg) allControls.append(self.infoLogo) allControls.append(self.infoChannelTitle) allControls.append(self.infoImg) allControls.append(self.infoTitle) allControls.append(self.infoDesc) allControls.append(self.infoPlot) allControls.append(self.infoNext) self.addControls(allControls) self.highlightImage.setImage(addonPath + '/resources/media/channel-highlight.png') self.infoPlot.autoScroll(5000, 1800, 5000) self.db = ZattooDB() if fav == 'popular': self.channels = self.db.getPopularList() else: self.channels = self.db.getChannelList(fav)
def create(self): """ internal: creates the control and adds it to the page assumes width/height etc are already set does not do navigation """ # get generic stuff, position, type, etc id = string.lower(self.getoption("id")) t = string.lower(self.getoption("type")) x = int(self.getvalue(self.getoption("posx"))) y = int(self.getvalue(self.getoption("posy"))) c=None # 0 means auto (afaik) w = 0 h = 0 t1 = self.getoption("width") if t1 != "": w = int(self.getvalue(t1)) t1 = self.getoption("height") if t1 != "": h = int(self.getvalue(t1)) l = self.getoption("label") try: t1 = int(l) l = self.translator.get(t1) except: pass help = self.getoption("help") try: t1 = int(help) help = self.translator.get(t1) except: pass self.options['help'] = help tx = self.getoption("texture") if tx != "": tx = util.findMediaFile( tx ) # if it didn't find the script skin file then use the xbmc skin file if tx == None: tx = self.getoption("texture") tx1 = self.getoption("texturefocus") if tx1 != "": tx1 = util.findMediaFile( tx1 ) tx2 = self.getoption("texturenofocus") if tx2 != "": tx2 = util.findMediaFile( tx2 ) ck = self.getoption("colorkey") aspectRatio = self.getoption("aspectratio") fnt = self.getvalue(self.getoption("font")) tcol = self.getoption("textcolor") log.debug( "id=[%s] x=[%d] y=[%d] w=[%d] h=[%d] font=[%s]"%(id,x,y,w,h,fnt) ) c = None if t == "image": try: if ck == "" and aspectRatio == "": c = xbmcgui.ControlImage(x,y,w,h,tx) elif aspectRatio != "": c = xbmcgui.ControlImage(x,y,w,h,tx, aspectRatio=int(aspectRatio)) else: c = xbmcgui.ControlImage(x,y,w,h,tx,ck) except Exception: log.exception("Unable to load image id:%s filename:%s" %(id, tx)) elif t == "button": try: tox = int(self.getvalue(self.getoption("offsetx"))) except: tox = 17 try: toy = int(self.getvalue(self.getoption("offsety"))) except: toy = 2 try: align = int(self.getvalue(self.getoption("alignment"))) except: align = 0 # left log.debug( "font=[%s] tox=[%d] toy=[%d] align=[%d]"%(fnt,tox,toy,align) ) if tx1 == "": if fnt == "": c = xbmcgui.ControlButton( x,y,w,h,l, textXOffset=int(tox),textYOffset=int(toy), alignment=align) else: c = xbmcgui.ControlButton( x,y,w,h,l,font=str(fnt), textXOffset=int(tox),textYOffset=int(toy), alignment=align) elif tx2 == "": if fnt == "": c = xbmcgui.ControlButton( x,y,w,h,l,tx1, textXOffset=int(tox),textYOffset=int(toy), alignment=align) else: c = xbmcgui.ControlButton( x,y,w,h,l,tx1,font=fnt, textXOffset=int(tox),textYOffset=int(toy), alignment=align) else: if fnt == "": c = xbmcgui.ControlButton( x, y, w, h, l, tx1, tx2, textXOffset=int(tox), textYOffset=int(toy), alignment=align) else: c = xbmcgui.ControlButton( x, y, w, h, l, tx1, tx2, font=fnt, textXOffset=int(tox), textYOffset=int(toy), alignment=align) elif t == "fadelabel": try: align = int(self.getvalue(self.getoption("alignment"))) except Exception: ## traceback.print_exc() ## print ( "XBMCMYTHTV: %s " % str(ex) ) align = 6 # left c = xbmcgui.ControlFadeLabel(x,y,w,h,str(fnt),tcol,alignment=align) elif t == "label": try: align = int(self.getvalue(self.getoption("alignment"))) except: align = 0 # left c = xbmcgui.ControlLabel(x,y,w,h,l,str(fnt),tcol,alignment=align) elif t == "listcontrol": try: tox = int(self.getvalue(self.getoption("offsetx"))) except: tox = 17 try: spc = int(self.getvalue(self.getoption("space"))) except: spc = 1 try: ih = int(self.getvalue(self.getoption( "itemheight" ))) except: ih = 20 # ALIGN_LEFT = 0 # ALIGN_RIGHT = 1 # ALIGN_CENTER_X = 2 # ALIGN_CENTER_Y = 4 # ALIGN_TRUNCATED = 8 bt = util.findMediaFile('button-focus.png') aly = ui.ALIGN_TRUNCATED | ui.ALIGN_CENTER_Y log.debug( "font=[%s] tox=[%d] ih=[%d]"%(fnt,tox,ih) ) if tx1 == "": if fnt == "": c = xbmcgui.ControlList(x,y,w,h,itemTextXOffset=int(tox),space=int(spc),itemHeight=int(ih), alignmentY = aly, buttonFocusTexture=bt) else: c = xbmcgui.ControlList(x,y,w,h,font=fnt,itemTextXOffset=int(tox),space=int(spc),itemHeight=int(ih), alignmentY = aly, buttonFocusTexture=bt) log.debug( "xbmcgui.ControlList(x,y,w,h)" ) elif tx2 == "": if fnt == "": c = xbmcgui.ControlList(x,y,w,h,tx1,itemTextXOffset=int(tox),space=int(spc),itemHeight=int(ih), alignmentY = aly, buttonFocusTexture=bt) else: c = xbmcgui.ControlList(x, y, w, h, tx1, font=fnt, itemTextXOffset=int(tox), space=int(spc), itemHeight=int(ih), alignmentY = aly, buttonFocusTexture=bt) log.debug( "xbmcgui.ControlList(x,y,w,h,tx1)" ) else: if fnt == "": c = xbmcgui.ControlList(x,y,w,h,tx1,tx2,itemTextXOffset=int(tox),space=int(spc),itemHeight=int(ih), alignmentY = aly, buttonFocusTexture=bt) else: c = xbmcgui.ControlList(x,y,w,h,tx1,tx2,font=fnt,itemTextXOffset=int(tox),space=int(spc),itemHeight=int(ih), alignmentY = aly, buttonFocusTexture=bt) log.debug( "xbmcgui.ControlList(x,y,w,h,tx1,tx2)" ) elif t == "textbox": c = xbmcgui.ControlTextBox(x,y,w,h,fnt,tcol) # c.setText() elif t == "checkmark": try: cw = int(self.getoption( "checkwidth" )) except: cw = 30 try: ch = int(self.getoption( "checkheight" )) except: ch = 30 try: align = int(self.getvalue(self.getoption("alignment"))) except: align = 1 # right if tx1 == "": c = xbmcgui.ControlCheckMark( x,y,w,h,l, checkWidth=cw, checkHeight=ch, alignment=align, textColor=tcol) elif tx2 == "": c = xbmcgui.ControlCheckMark( x,y,w,h,l,tx1, checkWidth=cw, checkHeight=ch, alignment=align, textColor=tcol) else: c = xbmcgui.ControlCheckMark( x,y,w,h,l,tx1,tx2,cw,ch,align,textColor=tcol) log.debug( "created '%s' control"%t ) # TODO: Remove OS specific checks if c != None: if os.name != "nt": self.owner.addControl(c) else: # lists are acting funny. trying remove instead of hide t1 = self.owner.getoption("defaultgroup") if t1 == self.getoption("group") or \ self.getoption("group") == "": self.owner.addControl(c) self.control = c
def addCtl(self, control): try: if (control['type'] == 'image'): if (control.has_key('info')): if (control['info'][0] != ''): control['texture'] = xbmc.getInfoImage( control['info'][0]) self.win.controls[int(control['id'])] = (xbmcgui.ControlImage(x=int(control['posx']) + self.posx,\ y=int(control['posy']) + self.posy, width=int(control['width']), height=int(control['height']),\ filename=control['texture'], colorKey=control['colorkey'], aspectRatio=int(control['aspectratio'])))#,\ #colorDiffuse=control['colordiffuse'])) self.win.addControl(self.win.controls[int(control['id'])]) elif (control['type'] == 'label'): if (control.has_key('info')): if (control['info'][0] != ''): control['label'][0] = xbmc.getInfoLabel( control['info'][0]) self.win.controls[int(control['id'])] = (xbmcgui.ControlLabel(x=int(control['posx']) + self.posx,\ y=int(control['posy']) + self.posy, width=int(control['width']), height=int(control['height']), label=control['label'][0],\ font=control['font'], textColor=control['textcolor'], disabledColor=control['disabledcolor'], alignment=control['align'],\ hasPath=control['haspath'], angle=int(control['angle'])))#, shadowColor=control['shadowcolor'])) self.win.addControl(self.win.controls[int(control['id'])]) elif (control['type'] == 'button'): if (control.has_key('info')): if (control['info'][0] != ''): control['label'][0] = xbmc.getInfoLabel( control['info'][0]) self.win.controls[int(control['id'])] = (xbmcgui.ControlButton(x=int(control['posx']) + self.posx,\ y=int(control['posy']) + self.posy, width=int(control['width']), height=int(control['height']), label=control['label'][0],\ font=control['font'], textColor=control['textcolor'], disabledColor=control['disabledcolor'], alignment=control['align'],\ angle=int(control['angle']), shadowColor=control['shadowcolor'], focusTexture=control['texturefocus'],\ noFocusTexture=control['texturenofocus'], textXOffset=int(control['textoffsetx']), textYOffset=int(control['textoffsety']))) self.win.addControl(self.win.controls[int(control['id'])]) elif (control['type'] == 'checkmark'): if (control.has_key('info')): if (control['info'][0] != ''): control['label'][0] = xbmc.getInfoLabel( control['info'][0]) self.win.controls[int(control['id'])] = (xbmcgui.ControlCheckMark(x=int(control['posx']) + self.posx,\ y=int(control['posy']) + self.posy, width=int(control['width']), height=int(control['height']), label=control['label'][0],\ font=control['font'], textColor=control['textcolor'], disabledColor=control['disabledcolor'], alignment=control['align'],\ focusTexture=control['texturecheckmark'], noFocusTexture=control['texturecheckmarknofocus'],\ checkWidth=int(control['markwidth']), checkHeight=int(control['markheight']))) self.win.addControl(self.win.controls[int(control['id'])]) elif (control['type'] == 'textbox'): self.win.controls[int(control['id'])] = (xbmcgui.ControlTextBox(x=int(control['posx']) + self.posx,\ y=int(control['posy']) + self.posy, width=int(control['width']), height=int(control['height']), font=control['font'],\ textColor=control['textcolor'])) self.win.addControl(self.win.controls[int(control['id'])]) if (control.has_key('label')): self.win.controls[int(control['id'])].setText( control['label'][0]) elif (control['type'] == 'fadelabel'): self.win.controls[int(control['id'])] = (xbmcgui.ControlFadeLabel(x=int(control['posx']) + self.posx,\ y=int(control['posy']) + self.posy, width=int(control['width']), height=int(control['height']), font=control['font'],\ textColor=control['textcolor'], alignment=control['align']))#, shadowColor=control['shadowcolor'])) self.win.addControl(self.win.controls[int(control['id'])]) if (control.has_key('info')): for item in control['info']: if (item != ''): self.win.controls[int(control['id'])].addLabel( xbmc.getInfoLabel(item)) if (control.has_key('label')): for item in control['label']: if (item != ''): self.win.controls[int( control['id'])].addLabel(item) elif (control['type'] == 'listcontrol'): self.win.controls[int(control['id'])] = (xbmcgui.ControlList(x=int(control['posx']) + self.posx,\ y=int(control['posy']) + self.posy, width=int(control['width']), height=int(control['height']), font=control['font'],\ textColor=control['textcolor'], alignmentY=control['aligny'], buttonTexture=control['texturenofocus'],\ buttonFocusTexture=control['texturefocus'], selectedColor=control['selectedcolor'], imageWidth=int(control['itemwidth']),\ imageHeight=int(control['itemheight']), itemTextXOffset=int(control['textxoff']), itemTextYOffset=int(control['textyoff']),\ itemHeight=int(control['textureheight']), space=int(control['spacebetweenitems'])))#, shadowColor=control['shadowcolor'])) self.win.addControl(self.win.controls[int(control['id'])]) if (control.has_key('label')): for cnt, item in enumerate(control['label']): if (item != ''): if (cnt < len(control['label2'])): tmp = control['label2'][cnt] else: tmp = '' if (cnt < len(control['image'])): tmp2 = control['image'][cnt] elif control['image']: tmp2 = control['image'][len(control['image']) - 1] else: tmp2 = '' l = xbmcgui.ListItem(item, tmp, '', tmp2) self.win.controls[int(control['id'])].addItem(l) try: self.win.visibility[int(control['id'])] = control['visible'] self.win.positions[int(control['id'])] = (int(control['posx']), int(control['posy'])) #self.win.onclick[int(control['id'])] = control['onclick'] #self.win.onfocus[int(control['id'])] = control['onfocus'] self.navigation[int(control['id'])] = (int(control['onup']), int(control['ondown']), int(control['onleft']), int(control['onright'])) self.win.controls[int(control['id'])].setVisible( xbmc.getCondVisibility(control['visible'])) except: pass except: if (not self.fastMethod): self.dlg.close() self.win.SUCCEEDED = False self.controlsFailed += control['id'] + ', ' self.controlsFailedCnt += 1
def __add_controles(self, list_controls, pos_ini): pos_x = self.screen_x + 20 width_control = self.screen_w - 75 pagina = 1 pos_y = pos_ini num_control = 0 for c in list_controls: # Fijar valores por defecto para cada control if not c.has_key('enabled') or c['enabled'] is None: c['enabled'] = True if not c.has_key('visible') or c['visible'] is None: c['visible'] = True if self.dict_values.has_key(c['id']): c['value'] = self.dict_values[c['id']] else: c['value'] = c['default'] c['pagina'] = pagina if c['type'] == 'bool': control = xbmcgui.ControlRadioButton( pos_x, pos_y, width_control, height=30, label=c['label'], font='font14', focusTexture=os.path.join(_path_imagen, 'Controls', 'MenuItemFO.png'), noFocusTexture=os.path.join(_path_imagen, 'Controls', 'MenuItemNF.png'), focusOnTexture=os.path.join(_path_imagen, 'Controls', 'radiobutton-focus.png'), noFocusOnTexture=os.path.join(_path_imagen, 'Controls', 'radiobutton-focus.png'), focusOffTexture=os.path.join(_path_imagen, 'Controls', 'radiobutton-nofocus.png'), noFocusOffTexture=os.path.join(_path_imagen, 'Controls', 'radiobutton-nofocus.png')) self.addControl(control) control.setRadioDimension(x=width_control - 30, y=0, width=30, height=30) control.setSelected(c['value']) c['control'] = control self.controles[control.getId()] = c elif c['type'] == 'text': control = xbmcgui.ControlEdit( -10, -10, width_control, 30, c['label'], font='font14', focusTexture=os.path.join(_path_imagen, 'Controls', 'MenuItemFO.png'), noFocusTexture=os.path.join(_path_imagen, 'Controls', 'MenuItemNF.png')) self.addControl(control) control.setLabel(c['label']) control.setText(c['value']) control.setPosition(pos_x + 10, pos_y) control.setWidth(width_control - 10) control.setHeight(30) c['control'] = control self.controles[control.getId()] = c elif c['type'] == 'list': control = ListControl(self, pos_x + 10, pos_y, width_control, 30, c['label'], c['lvalues'], c['value']) self.addControl(control) c['control'] = control self.controles[control.getId() - 1] = c # Boton up self.controles[control.getId() - 2] = c # Boton down elif c['type'] == 'label': if c['default'].startswith('0x'): control = xbmcgui.ControlFadeLabel(pos_x + 10, pos_y, width_control, height=30, font='font24_title', textColor=c['default']) else: control = xbmcgui.ControlFadeLabel(pos_x + 10, pos_y, width_control, height=30, font='font24_title', textColor='0xFF0066CC') self.addControl(control) control.addLabel(c['label']) c['control'] = control self.controles[control.getId()] = c else: # Control no soportado return # Comun para todos los controles control.setEnabled(c['enabled']) if c['visible']: pos_y += 30 control.setVisible(pagina == 1) num_control += 1 else: control.setVisible(False) if (num_control % self.num_controles_x_page) == 0: pos_y = pos_ini pagina += 1 return
def set_controls(self): # Демонстрация основных контролов XBMC UI. # При первоначальном создании задаются фиктивные координаты и размеры: 1, 1, 1, 1. no_int_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'Вывод информации', alignment=ALIGN_CENTER) self.placeControl(no_int_label, 0, 0, 1, 2) label_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'ControlLabel') self.placeControl(label_label, 1, 0) # ControlLabel self.label = xbmcgui.ControlLabel(1, 1, 1, 1, u'Простая надпись') self.placeControl(self.label, 1, 1) fadelabel_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'ControlFadeLabel') self.placeControl(fadelabel_label, 2, 0) # ControlFadeLabel self.fade_label = xbmcgui.ControlFadeLabel(1, 1, 1, 1) self.placeControl(self.fade_label, 2, 1) # Дополнительные свойства определяем после (!!!) отображения контрола. self.fade_label.addLabel(u'Здесь может быть очень длинная строка.') textbox_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'ControlTextBox') self.placeControl(textbox_label, 3, 0) # ControlTextBox self.textbox = xbmcgui.ControlTextBox(1, 1, 1, 1) self.placeControl(self.textbox, 3, 1, 2, 1) self.textbox.setText(u'Текстовое окно.\n' u'Здесь может быть несколько строк.\n') image_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'ControlImage') self.placeControl(image_label, 5, 0) # ControlImage self.image = xbmcgui.ControlImage(1, 1, 1, 1, os.path.join(images, 'banner.jpg')) self.placeControl(self.image, 5, 1) no_int_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'Интерактивные элементы', alignment=ALIGN_CENTER) self.placeControl(no_int_label, 6, 0, 1, 2) button_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'ControlButton') self.placeControl(button_label, 7, 0) # ControlButton self.button = xbmcgui.ControlButton( 1, 1, 1, 1, u'Нажми меня', focusTexture=self.button_bg_focus, noFocusTexture=self.button_bg_Nofocus, alignment=ALIGN_CENTER) self.placeControl(self.button, 7, 1) radiobutton_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'ControlRadioButton') self.placeControl(radiobutton_label, 8, 0) # ControlRadioButton self.radiobutton = xbmcgui.ControlRadioButton( 1, 1, 1, 1, u'Радиокнопка', focusTexture=self.list_bg_focus, noFocusTexture=self.list_bg_Nofocus, TextureRadioFocus=self.radio_focus, TextureRadioNoFocus=self.radio_Nofocus) self.placeControl(self.radiobutton, 8, 1) edit_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'ControlEdit') self.placeControl(edit_label, 9, 0) # ControlEdit self.edit = xbmcgui.ControlEdit(1, 1, 1, 1, '', focusTexture=self.edit_focus, noFocusTexture=self.button_bg_Nofocus, _alignment=ALIGN_LEFT) self.placeControl(self.edit, 9, 1) self.edit.setText(u'Введите текст сюда') list_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'ControlList') self.placeControl(list_label, 10, 0) # ControlList self.list = xbmcgui.ControlList(1, 1, 1, 1, buttonTexture=self.list_bg_Nofocus, buttonFocusTexture=self.list_bg_focus) self.placeControl(self.list, 10, 1, 3, 1) self.list.addItems([u'Объект 1', u'Объект 2', u'Объект 3']) slider_label = xbmcgui.ControlLabel(1, 1, 1, 1, 'ControlSlider') self.placeControl(slider_label, 13, 0) # ControlSlider self.slider = xbmcgui.ControlSlider(1, 1, 1, 1, textureback=self.slider_bg, texture=self.slider_nib_nf, texturefocus=self.slider_nib) self.placeControl(self.slider, 13, 1) self.slider.setPercent(25)