def init_cycle_controls(self):
#self.log(' init_cycle_controls start')
for _ in xrange(self.IMAGE_CONTROL_COUNT):
img_control = ControlImage(0, 0, 0, 0, '', aspectRatio=2) #(values 0 = stretch (default), 1 = scale up (crops), 2 = scale down (black bars)
txt_control = ControlTextBox(0, 0, 0, 0, font='font16')
# xbfont_left = 0x00000000
# xbfont_right = 0x00000001
# xbfont_center_x = 0x00000002
# xbfont_center_y = 0x00000004
# xbfont_truncated = 0x00000008
#ControlLabel(x, y, width, height, label, font=None, textColor=None, disabledColor=None, alignment=0, hasPath=False, angle=0)
#txt_control = ControlLabel(0, 0, 0, 0, '', font='font30', textColor='', disabledColor='', alignment=6, hasPath=False, angle=0)
#self.image_controls.append(img_control)
self.tni_controls.append([txt_control,img_control])
#self.log(' init_cycle_controls end')
python类ControlLabel()的实例源码
def __init__(self):
self.skipSeconds = float(FIRST_SKIP_SECONDS)
self.cumulativeSkipSeconds = 0.0
self.startTime = None
self.previousDirection = None
self.directionChanged = False
self.addControl(xbmcgui.ControlImage(10, 10, 200, 90, addon.getAddonInfo('path')+'/resources/media/background.png'))
self.controlLabel1 = xbmcgui.ControlLabel(x=20, y=20, width=180, height=30, label="", alignment=xbfont_center_y|xbfont_center_x)
self.addControl(self.controlLabel1)
self.controlLabel1.setLabel(i18n_jump + ": " + str(FIRST_SKIP_SECONDS) + " " + i18n_sec)
self.controlLabel2 = xbmcgui.ControlLabel(x=20, y=60, width=180, height=30, label="", alignment=xbfont_center_y|xbfont_center_x)
self.addControl(self.controlLabel2)
self.controlLabel2.setLabel(i18n_place + ": +00:00:00")
def getLabel(imagecontrol,label):
#image control
image_position = imagecontrol.getPosition()
image_height = imagecontrol.getHeight()
image_width = imagecontrol.getWidth()
#label control
label_x = int(image_position[0]-0.5*image_width)
label_y = int(image_position[1]+image_height-0.04*image_height)
label_height = int(0.2*image_height)
label_width = int(2*image_width)
return xbmcgui.ControlLabel(label_x, label_y, label_width, label_height, label, alignment = 0x00000002, font="font10", textColor="0xFFEB9E17")
def __init__(self, *args, **kwargs):
self.window = xbmcgui.Window(WINDOW_FULLSCREEN_VIDEO)
viewport_w, viewport_h = self._get_skin_resolution()
# Adjust size based on viewport, we are using 1080p coordinates
self._shown = False
self._text = ""
self._label = xbmcgui.ControlLabel(int(viewport_w*0.7), int(viewport_h*0.10), int(viewport_w*0.3), int(viewport_h*0.8),
self._text,alignment=0)
def add_control_label(self, c):
control = xbmcgui.ControlLabel(0, -100, self.controls_width, 30, "", alignment=4, font=self.font, textColor=c["color"])
self.addControl(control)
control.setVisible(False)
control.setLabel(c["label"])
# Lo añadimos al listado
c["control"] = control
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 __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 stack_cycle_controls(self):
for txt_ctl, img_ctl in self.tni_controls:
self.xbmc_window.addControl(img_ctl)
if self.SHOW_TITLE:
self.txt_background=ControlImage(0, 685, 1280, 40, 'srr_dialog-bg.png', aspectRatio=1)
self.xbmc_window.addControl( self.txt_background )
#ControlLabel(x, y, width, height, label, font=None, textColor=None, disabledColor=None, alignment=0, hasPath=False, angle=0)
self.image_label=ControlLabel(10,688,1280,30,'',font='font16', textColor='', disabledColor='', alignment=6, hasPath=False, angle=0)
self.xbmc_window.addControl( self.image_label )
#for txt_ctl, img_ctl in self.tni_controls:
# self.xbmc_window.addControl(txt_ctl)
def add_control_label(self, c):
control = xbmcgui.ControlLabel(0, -100, self.controls_width, 30, "", alignment=4, font=self.font,
textColor=c["color"])
self.addControl(control)
control.setVisible(False)
control.setLabel(c["label"])
# Lo añadimos al listado
c["control"] = control
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 __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 __init__(self, line=''):
self.addControl(xbmcgui.ControlLabel(x=390, y=5, width=500, height=25, label=line, textColor='0xFFFFFF00'))
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 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