From 1efbb50d3ab02af155035404ffc107c275799f8d Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Tue, 10 Jun 2008 07:43:48 +0000 Subject: [PATCH 1/1] add MultiColorLabel in the skin you can set multiple colors with foregroundColors="#8c7c93,black,#f23d21" and/or backgroundColors="#012345,#081501,green,#078753" in python code the you can switch colors with self["blasel"].setForegroundColorNum(x) or self["blubber"].setBackgroundColorNum(y) --- lib/python/Components/Label.py | 42 +++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/lib/python/Components/Label.py b/lib/python/Components/Label.py index 7e61275b..5f74b75c 100644 --- a/lib/python/Components/Label.py +++ b/lib/python/Components/Label.py @@ -1,7 +1,7 @@ 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 @@ -37,3 +37,43 @@ 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 + -- 2.30.2