我们从Python开源项目中,提取了以下21个代码示例,用于说明如何使用xbmcgui.ControlButton()。
def __init__(self, cookie, tokens, vcodetype, codeString, vcode_path): self.cookie = cookie self.tokens = tokens self.vcodetype = vcodetype self.codeString = codeString self.vcode_path = vcode_path # windowItems self.image = xbmcgui.ControlImage(80, 100, 500, 200, self.vcode_path) self.buttonInput = xbmcgui.ControlButton( 100, 330, 220, 50, label=u'?????', alignment=6, font='font13', textColor='0xFFFFFFFF' ) self.buttonRefresh = xbmcgui.ControlButton( 290, 330, 220, 50, label=u'?????', alignment=6, font='font13', textColor='0xFFFFFFFF' ) self.addControls([self.image, self.buttonInput, self.buttonRefresh]) self.buttonInput.controlRight(self.buttonRefresh) self.buttonRefresh.controlLeft(self.buttonInput) self.setFocus(self.buttonInput)
def process_clicked_item(self, clicked_item): if isinstance(clicked_item, xbmcgui.ListItem ): di_url=clicked_item.getProperty('onClick_action') #this property is created when assembling the kwargs.get("listing") for this class item_type=clicked_item.getProperty('item_type').lower() elif isinstance(clicked_item, xbmcgui.ControlButton ): #buttons have no setProperty() hiding it in Label2 no good. #ast.literal_eval(cxm_string): #di_url=clicked_item.getLabel2() #log(' button label2='+repr(di_url)) #item_type=clicked_item.getProperty('item_type').lower() pass log( " clicked %s IsPlayable=%s url=%s " %( repr(clicked_item),item_type, di_url ) ) if item_type=='playable': #a big thank you to spoyser (http://forum.kodi.tv/member.php?action=profile&uid=103929) for this help pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) pl.clear() pl.add(di_url, clicked_item) xbmc.Player().play(pl, windowed=False) elif item_type=='script': #if user clicked on 'next' we close this screen and load the next page. if 'mode=listSubReddit' in di_url: self.busy_execute_sleep(di_url,500,True ) else: self.busy_execute_sleep(di_url,3000,False )
def add_control_list(self, c): control = xbmcgui.ControlButton(0, -100, self.controls_width, self.height_control, c["label"], os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), os.path.join(self.mediapath, 'Controls','MenuItemNF.png'), 0, textColor=c["color"], font=self.font) label = xbmcgui.ControlLabel(0, -100, self.controls_width - 30, self.height_control, "", font=self.font, textColor=c["color"], alignment=4 | 1) upBtn = xbmcgui.ControlButton(0, -100, 20, 15, "", focusTexture=os.path.join(self.mediapath, 'Controls', 'spinUp-Focus.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'spinUp-noFocus.png')) downBtn = xbmcgui.ControlButton(0, -100 + 15, 20, 15, "", focusTexture=os.path.join(self.mediapath, 'Controls', 'spinDown-Focus.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'spinDown-noFocus.png')) self.addControl(control) self.addControl(label) self.addControl(upBtn) self.addControl(downBtn) control.setVisible(False) label.setVisible(False) upBtn.setVisible(False) downBtn.setVisible(False) label.setLabel(c["lvalues"][self.values[c["id"]]]) c["control"] = control c["label"] = label c["downBtn"] = downBtn c["upBtn"] = upBtn
def __new__(cls, *args, **kwargs): del kwargs["isPassword"] del kwargs["window"] args = list(args) return xbmcgui.ControlButton.__new__(cls, *args, **kwargs)
def setLabel(self, val): self.label = val xbmcgui.ControlButton.setLabel(self, val)
def getX(self): return xbmcgui.ControlButton.getPosition(self)[0]
def setEnabled(self, e): xbmcgui.ControlButton.setEnabled(self, e) self.textControl.setEnabled(e)
def setWidth(self, w): xbmcgui.ControlButton.setWidth(self, w) self.textControl.setWidth(w/2)
def setHeight(self, w): xbmcgui.ControlButton.setHeight(self, w) self.textControl.setHeight(w)
def setPosition(self, x, y): xbmcgui.ControlButton.setPosition(self, x, y) if xbmcgui.__version__ == "1.2": self.textControl.setPosition(x + self.getWidth(), y) else: self.textControl.setPosition(x + self.getWidth() / 2, y)
def add_control_list(self, c): control = xbmcgui.ControlButton(0, -100, self.controls_width, self.height_control, c["label"], os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'), os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png'), 0, textColor=c["color"], font=self.font) label = xbmcgui.ControlLabel(0, -100, self.controls_width - 30, self.height_control, "", font=self.font, textColor=c["color"], alignment=4 | 1) upBtn = xbmcgui.ControlButton(0, -100, 20, 15, "", focusTexture=os.path.join(self.mediapath, 'Controls', 'spinUp-Focus.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'spinUp-noFocus.png')) downBtn = xbmcgui.ControlButton(0, -100 + 15, 20, 15, "", focusTexture=os.path.join(self.mediapath, 'Controls', 'spinDown-Focus.png'), noFocusTexture=os.path.join(self.mediapath, 'Controls', 'spinDown-noFocus.png')) self.addControl(control) self.addControl(label) self.addControl(upBtn) self.addControl(downBtn) control.setVisible(False) label.setVisible(False) upBtn.setVisible(False) downBtn.setVisible(False) label.setLabel(c["lvalues"][self.values[c["id"]]]) c["control"] = control c["label"] = label c["downBtn"] = downBtn c["upBtn"] = upBtn
def setWidth(self, w): xbmcgui.ControlButton.setWidth(self, w) self.textControl.setWidth(w / 2)
def onAction(self, action): self.close() # TODO mirar retro-compatiblidad # class ControlEdit(xbmcgui.ControlButton): # def __new__(self, *args, **kwargs): # del kwargs["isPassword"] # del kwargs["window"] # args = list(args) # return xbmcgui.ControlButton.__new__(self, *args, **kwargs) # # def __init__(self, *args, **kwargs): # self.isPassword = kwargs["isPassword"] # self.window = kwargs["window"] # self.label = "" # self.text = "" # self.textControl = xbmcgui.ControlLabel(self.getX(), self.getY(), self.getWidth(), self.getHeight(), # self.text, # font=kwargs["font"], textColor=kwargs["textColor"], alignment=4 | 1) # self.window.addControl(self.textControl) # # def setLabel(self, val): # self.label = val # xbmcgui.ControlButton.setLabel(self, val) # # def getX(self): # return xbmcgui.ControlButton.getPosition(self)[0] # # def getY(self): # return xbmcgui.ControlButton.getPosition(self)[1] # # def setEnabled(self, e): # xbmcgui.ControlButton.setEnabled(self, e) # self.textControl.setEnabled(e) # # def setWidth(self, w): # xbmcgui.ControlButton.setWidth(self, w) # self.textControl.setWidth(w / 2) # # def setHeight(self, w): # xbmcgui.ControlButton.setHeight(self, w) # self.textControl.setHeight(w) # # def setPosition(self, x, y): # xbmcgui.ControlButton.setPosition(self, x, y) # self.textControl.setPosition(x + self.getWidth() / 2, y) # # def setText(self, text): # self.text = text # if self.isPassword: # self.textControl.setLabel("*" * len(self.text)) # else: # self.textControl.setLabel(self.text) # # def getText(self): # return self.text # # # if not hasattr(xbmcgui, "ControlEdit"): # xbmcgui.ControlEdit = ControlEdit
def onInit(self): xbmc.executebuiltin( "Dialog.Close(busydialog)" ) #important to reset the listbox. when control comes back to this GUI(after calling another gui). # kodi will "onInit" this GUI again. we end up adding items in gui_listbox #self.gui_listbox.reset() #self.exit_monitor = ExitMonitor(self.close_gui)#monitors for abortRequested and calls close on the gui if self.title_bar_text: self.ctl_title_bar = self.getControl(1) self.ctl_title_bar.setText(self.title_bar_text) if self.poster: #self.getControl(2).setImage(self.poster) self.getControl(3).setImage(self.poster) listing_generator=generator(self.listing) for control_id in self.x_controls: tx_control=self.getControl(control_id) bn_control=self.getControl(control_id+1000) img_control=self.getControl(control_id+2000) try: #gether the listitem properties and prepare to put them on the button li=listing_generator.next() link_url=li.getProperty('link_url') label=li.getLabel() label=label.replace(link_url, "") #remove the http:... part to avoid it looking duplicated because it is already put as a label in button. thumb=li.getArt('thumb') log('item_type='+repr(li.getProperty('item_type')) ) log('onClick_action='+repr(li.getProperty('onClick_action')) ) except StopIteration: li=label=link_url=None if label: tx_control.setText(label) #xbmcgui.ControlButton object has no attribute 'setProperty' if link_url=='http://blank.padding': #the regex generating this list is not perfect. a padding was added to make it work. we ignore it here. bn_control.setVisible(False) else: bn_control.setLabel(label=link_url) else: tx_control.setText(None) tx_control.setVisible(False) bn_control.setVisible(False) if thumb: img_control.setImage(thumb) else: img_control.setVisible(False) #hide the unused controls so they don't occupy 'space' in the grouplist