From f588b9f1d77b45444d59ed7409e062580a3848f0 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Sun, 13 Apr 2008 22:32:36 +0000 Subject: [PATCH 1/1] add TemplatedMultiContent converter --- lib/python/Components/Converter/Makefile.am | 2 +- .../Converter/TemplatedMultiContent.py | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 lib/python/Components/Converter/TemplatedMultiContent.py diff --git a/lib/python/Components/Converter/Makefile.am b/lib/python/Components/Converter/Makefile.am index f5188090..0fff9c8d 100644 --- a/lib/python/Components/Converter/Makefile.am +++ b/lib/python/Components/Converter/Makefile.am @@ -5,5 +5,5 @@ install_PYTHON = \ Poll.py RemainingToText.py StringList.py ServiceName.py FrontendInfo.py ServiceInfo.py \ ConditionalShowHide.py ServicePosition.py ValueRange.py RdsInfo.py Streaming.py \ StaticMultiList.py ServiceTime.py MovieInfo.py MenuEntryCompare.py StringListSelection.py \ - ValueBitTest.py TunerInfo.py ConfigEntryTest.py + ValueBitTest.py TunerInfo.py ConfigEntryTest.py TemplatedMultiContent.py diff --git a/lib/python/Components/Converter/TemplatedMultiContent.py b/lib/python/Components/Converter/TemplatedMultiContent.py new file mode 100644 index 00000000..a1b601d6 --- /dev/null +++ b/lib/python/Components/Converter/TemplatedMultiContent.py @@ -0,0 +1,34 @@ +from Components.Converter.StringList import StringList + +class TemplatedMultiContent(StringList): + """Turns a python tuple list into a multi-content list which can be used in a listbox renderer.""" + def __init__(self, args): + StringList.__init__(self, args) + from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_HALIGN_RIGHT, RT_VALIGN_TOP, RT_VALIGN_CENTER, RT_VALIGN_BOTTOM + from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmap, MultiContentEntryPixmapAlphaTest + l = locals() + del l["self"] # cleanup locals a bit + del l["args"] + + self.template = eval(args, {}, l) + assert "fonts" in self.template + assert "itemHeight" in self.template + assert "template" in self.template + + def changed(self, what): + if not self.content: + from enigma import eListboxPythonMultiContent + self.content = eListboxPythonMultiContent() + self.content.setItemHeight(self.template["itemHeight"]) + self.content.setTemplate(self.template["template"]) + + # also setup fonts (also given by source) + index = 0 + for f in self.template["fonts"]: + self.content.setFont(index, f) + index += 1 + + if self.source: + self.content.setList(self.source.list) + + self.downstream_elements.changed(what) -- 2.30.2