enigma2 (20120327 rel32 -> 20120430 master)
[enigma2.git] / usr / lib / enigma2 / python / Components / Converter / StringListSelection.py
1 from Components.Converter.Converter import Converter
2 from Components.Element import cached
3
4 class StringListSelection(Converter, object):
5         "extracts the first element of a the current string list  element for displaying it on LCD"
6         def __init__(self, args):
7                 Converter.__init__(self, args)
8                 if args.isdigit():
9                         self.element_index = int(args)
10                 else:
11                         self.element_index = 0
12
13         def selChanged(self):
14                 self.downstream_elements.changed((self.CHANGED_ALL, 0))
15
16         @cached
17         def getText(self):
18                 cur = self.source.current
19                 if cur and len(cur):
20                         return cur[self.element_index]
21                 return None
22
23         text = property(getText)
24
25         def changed(self, what):
26                 if what[0] == self.CHANGED_DEFAULT:
27                         self.source.onSelectionChanged.append(self.selChanged)
28                 Converter.changed(self, what)