ServiceName converter now can handle iPlayableService's and
[enigma2.git] / lib / python / Components / ChoiceList.py
1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
3 from MenuList import MenuList
4 from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename
5 from enigma import RT_HALIGN_LEFT, eListboxPythonMultiContent, eListbox, gFont, loadPNG
6
7 def ChoiceEntryComponent(key, text):
8         res = [ text ]
9         if text[0] == "--":
10                 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 00, 800, 25, 0, RT_HALIGN_LEFT, "-"*200))
11         else:
12                 res.append((eListboxPythonMultiContent.TYPE_TEXT, 32, 00, 800, 25, 0, RT_HALIGN_LEFT, text[0]))
13         
14                 png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "key_" + key + "-fs8.png"))
15                 if png is not None:
16                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 30, 20, png))
17         
18         return res
19
20 class ChoiceList(MenuList, HTMLComponent, GUIComponent):
21         def __init__(self, list, selection = 0):
22                 GUIComponent.__init__(self)
23                 self.l = eListboxPythonMultiContent()
24                 self.list = list
25                 self.l.setList(list)
26                 self.l.setFont(0, gFont("Regular", 20))
27                 self.l.setItemHeight(25)
28                 self.selection = selection
29
30         GUI_WIDGET = eListbox
31                 
32         def postWidgetCreate(self, instance):
33                 instance.setContent(self.l)
34                 self.moveToIndex(self.selection)