X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/572caca1ba06dd8247724c9f5d6bcad515e2edf4..1efbb50d3ab02af155035404ffc107c275799f8d:/lib/python/Components/Label.py diff --git a/lib/python/Components/Label.py b/lib/python/Components/Label.py index c2d57743..5f74b75c 100644 --- a/lib/python/Components/Label.py +++ b/lib/python/Components/Label.py @@ -1,10 +1,12 @@ -from HTMLComponent import * -from GUIComponent import * -from VariableText import * +from HTMLComponent import HTMLComponent +from GUIComponent import GUIComponent +from VariableText import VariableText +from skin import parseColor +from ConditionalWidget import ConditionalWidget, BlinkingWidget, BlinkingWidgetConditional from enigma import eLabel -class Label(HTMLComponent, GUIComponent, VariableText): +class Label(VariableText, HTMLComponent, GUIComponent): def __init__(self, text=""): GUIComponent.__init__(self) VariableText.__init__(self) @@ -15,15 +17,63 @@ class Label(HTMLComponent, GUIComponent, VariableText): return self.getText() # GUI: - def createWidget(self, parent): - return eLabel(parent) - + GUI_WIDGET = eLabel + def getSize(self): s = self.instance.calculateSize() return (s.width(), s.height()) - def show(self): - self.instance.show() +class LabelConditional(Label, ConditionalWidget): + def __init__(self, text = "", withTimer = True): + ConditionalWidget.__init__(self, withTimer = withTimer) + Label.__init__(self, text = text) + +class BlinkingLabel(Label, BlinkingWidget): + def __init__(self, text = ""): + Label.__init__(text = text) + BlinkingWidget.__init__() + +class BlinkingLabelConditional(BlinkingWidgetConditional, LabelConditional): + def __init__(self, text = ""): + LabelConditional.__init__(self, text = text) + BlinkingWidgetConditional.__init__(self) + +class MultiColorLabel(Label): + def __init__(self, text=""): + Label.__init__(self,text) + self.foreColors = [] + self.backColors = [] + + def applySkin(self, desktop, screen): + if self.skinAttributes is not None: + attribs = [ ] + for (attrib, value) in self.skinAttributes: + if attrib == "foregroundColors": + colors = value.split(',') + attribs.append(("foregroundColor",colors[0] )) + for color in colors: + self.foreColors.append(parseColor(color)) + elif attrib == "backgroundColors": + colors = value.split(',') + attribs.append(("backgroundColor",colors[0] )) + for color in colors: + self.backColors.append(parseColor(color)) + else: + attribs.append((attrib,value)) + self.skinAttributes = attribs + return GUIComponent.applySkin(self, desktop, screen) + + def setForegroundColorNum(self, x): + if self.instance: + if len(self.foreColors) > x: + self.instance.setForegroundColor(self.foreColors[x]) + else: + print "setForegroundColorNum(%d) failed! defined colors:" %(x), self.foreColors + + def setBackgroundColorNum(self, x): + if self.instance: + if len(self.backColors) > x: + self.instance.setBackgroundColor(self.backColors[x]) + else: + print "setBackgroundColorNum(%d) failed! defined colors:" %(x), self.backColors - def hide(self): - self.instance.hide()