33868d610ade518f12703f2e01152589f90e16d7
[openblackhole/openblackhole-enigma2.git] / lib / python / Components / ChoiceList.py
1 from MenuList import MenuList
2 from Tools.Directories import SCOPE_CURRENT_SKIN, resolveFilename
3 from enigma import RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
4 from Tools.LoadPixmap import LoadPixmap
5
6 def ChoiceEntryComponent(key = "", text = ["--"]):
7         res = [ text ]
8         if text[0] == "--":
9                 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 00, 800, 25, 0, RT_HALIGN_LEFT, "-"*200))
10         else:
11                 res.append((eListboxPythonMultiContent.TYPE_TEXT, 45, 00, 800, 25, 0, RT_HALIGN_LEFT, text[0]))
12         
13                 png = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/key_" + key + ".png"))
14                 if png is not None:
15                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 0, 35, 25, png))
16         
17         return res
18
19 class ChoiceList(MenuList):
20         def __init__(self, list, selection = 0, enableWrapAround=False):
21                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
22                 self.l.setFont(0, gFont("Regular", 20))
23                 self.l.setItemHeight(25)
24                 self.selection = selection
25
26         def postWidgetCreate(self, instance):
27                 MenuList.postWidgetCreate(self, instance)
28                 self.moveToIndex(self.selection)