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:
49 foregroundColor = None
50 backgroundColor = None
52 for (attrib, value) in self.skinAttributes:
53 if attrib == "foregroundColors":
54 colors = value.split(',')
56 self.foreColors.append(parseColor(color))
57 if not foregroundColor:
58 foregroundColor = colors[0]
59 elif attrib == "backgroundColors":
60 colors = value.split(',')
62 self.backColors.append(parseColor(color))
63 if not backgroundColor:
64 backgroundColor = colors[0]
65 elif attrib == "backgroundColor":
66 backgroundColor = value
67 elif attrib == "foregroundColor":
68 foregroundColor = value
70 attribs.append((attrib,value))
72 attribs.append(("foregroundColor",foregroundColor))
74 attribs.append(("backgroundColor",backgroundColor))
75 self.skinAttributes = attribs
76 return GUIComponent.applySkin(self, desktop, screen)
78 def setForegroundColorNum(self, x):
80 if len(self.foreColors) > x:
81 self.instance.setForegroundColor(self.foreColors[x])
83 print "setForegroundColorNum(%d) failed! defined colors:" %(x), self.foreColors
85 def setBackgroundColorNum(self, x):
87 if len(self.backColors) > x:
88 self.instance.setBackgroundColor(self.backColors[x])
90 print "setBackgroundColorNum(%d) failed! defined colors:" %(x), self.backColors