a1b601d66002b04ee4d8195f513d59a2a79692a0
[vuplus_dvbapp] / lib / python / Components / Converter / TemplatedMultiContent.py
1 from Components.Converter.StringList import StringList
2
3 class TemplatedMultiContent(StringList):
4         """Turns a python tuple list into a multi-content list which can be used in a listbox renderer."""
5         def __init__(self, args):
6                 StringList.__init__(self, args)
7                 from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_HALIGN_RIGHT, RT_VALIGN_TOP, RT_VALIGN_CENTER, RT_VALIGN_BOTTOM
8                 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmap, MultiContentEntryPixmapAlphaTest
9                 l = locals()
10                 del l["self"] # cleanup locals a bit
11                 del l["args"]
12
13                 self.template = eval(args, {}, l)
14                 assert "fonts" in self.template
15                 assert "itemHeight" in self.template
16                 assert "template" in self.template
17
18         def changed(self, what):
19                 if not self.content:
20                         from enigma import eListboxPythonMultiContent
21                         self.content = eListboxPythonMultiContent()
22                         self.content.setItemHeight(self.template["itemHeight"])
23                         self.content.setTemplate(self.template["template"])
24
25                         # also setup fonts (also given by source)
26                         index = 0
27                         for f in self.template["fonts"]:
28                                 self.content.setFont(index, f)
29                                 index += 1
30
31                 if self.source:
32                         self.content.setList(self.source.list)
33
34                 self.downstream_elements.changed(what)