Let ChoiceBox font and calculated size be set from the aliasses.
[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 import skin
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, 45, 00, 800, 25, 0, RT_HALIGN_LEFT, text[0]))
13         
14                 png = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/key_" + key + ".png"))
15                 if png is not None:
16                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 5, 0, 35, 25, png))
17         
18         return res
19
20 class ChoiceList(MenuList):
21         def __init__(self, list, selection = 0, enableWrapAround=False):
22                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
23                 font = skin.fonts["ChoiceList"]
24                 self.l.setFont(0, gFont(font[0], font[1]))
25                 self.l.setItemHeight(font[2])
26                 self.selection = selection
27
28         def postWidgetCreate(self, instance):
29                 MenuList.postWidgetCreate(self, instance)
30                 self.moveToIndex(self.selection)