1 from Converter import Converter
2 from enigma import eListboxPythonStringContent
3 from Components.Element import cached
5 class StringList(Converter):
6 """Turns a simple python list into a list which can be used in a listbox."""
7 def __init__(self, type):
8 Converter.__init__(self, type)
11 def changed(self, what):
13 self.content = eListboxPythonStringContent()
16 self.content.setList(self.source.list)
17 self.downstream_elements.changed(what)
19 def selectionChanged(self, index):
20 self.source.selectionChanged(index)
22 def setIndex(self, index):
23 # update all non-master targets
24 for x in self.downstream_elements:
25 if x is not self.master:
28 def getIndex(self, index):
31 index = property(getIndex, setIndex)
35 if self.source is None or self.index is None or self.index >= len(self.source.list):
37 return self.source.list[self.index]
39 current = property(getCurrent)
41 # pass through: getIndex / setIndex to master
44 if self.master is None:
46 return self.master.index
48 def setIndex(self, index):
49 if self.master is not None:
50 self.master.index = index
52 index = property(getIndex, setIndex)
54 def entry_changed(self, index):
55 self.downstream_elements.entry_changed(index)