diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-06-10 07:43:48 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2008-06-10 07:43:48 +0000 |
| commit | 1efbb50d3ab02af155035404ffc107c275799f8d (patch) | |
| tree | 0a45347b4e83fa56f57adb272b956c157b1950b8 /lib/python/Components | |
| parent | 3d8ffc3281925011e894d57a9f51423736ee891a (diff) | |
| download | enigma2-1efbb50d3ab02af155035404ffc107c275799f8d.tar.gz enigma2-1efbb50d3ab02af155035404ffc107c275799f8d.zip | |
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)
Diffstat (limited to 'lib/python/Components')
| -rw-r--r-- | lib/python/Components/Label.py | 42 |
1 files changed, 41 insertions, 1 deletions
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 + |
