1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
3 from VariableText import VariableText
4 from skin import parseColor
5 from ConditionalWidget import ConditionalWidget, BlinkingWidget, BlinkingWidgetConditional
7 from enigma import eLabel
9 class Label(VariableText, HTMLComponent, GUIComponent):
10 def __init__(self, text=""):
11 GUIComponent.__init__(self)
12 VariableText.__init__(self)
16 def produceHTML(self):
23 s = self.instance.calculateSize()
24 return (s.width(), s.height())
26 class LabelConditional(Label, ConditionalWidget):
27 def __init__(self, text = "", withTimer = True):
28 ConditionalWidget.__init__(self, withTimer = withTimer)
29 Label.__init__(self, text = text)
31 class BlinkingLabel(Label, BlinkingWidget):
32 def __init__(self, text = ""):
33 Label.__init__(text = text)
34 BlinkingWidget.__init__()
36 class BlinkingLabelConditional(BlinkingWidgetConditional, LabelConditional):
37 def __init__(self, text = ""):
38 LabelConditional.__init__(self, text = text)
39 BlinkingWidgetConditional.__init__(self)
41 class MultiColorLabel(Label):
42 def __init__(self, text=""):
43 Label.__init__(self,text)
47 def applySkin(self, desktop, screen):
48 if self.skinAttributes is not None:
50 for (attrib, value) in self.skinAttributes:
51 if attrib == "foregroundColors":
52 colors = value.split(',')
53 attribs.append(("foregroundColor",colors[0] ))
55 self.foreColors.append(parseColor(color))
56 elif attrib == "backgroundColors":
57 colors = value.split(',')
58 attribs.append(("backgroundColor",colors[0] ))
60 self.backColors.append(parseColor(color))
62 attribs.append((attrib,value))
63 self.skinAttributes = attribs
64 return GUIComponent.applySkin(self, desktop, screen)
66 def setForegroundColorNum(self, x):
68 if len(self.foreColors) > x:
69 self.instance.setForegroundColor(self.foreColors[x])
71 print "setForegroundColorNum(%d) failed! defined colors:" %(x), self.foreColors
73 def setBackgroundColorNum(self, x):
75 if len(self.backColors) > x:
76 self.instance.setBackgroundColor(self.backColors[x])
78 print "setBackgroundColorNum(%d) failed! defined colors:" %(x), self.backColors