Support duo4k.
[vuplus_dvbapp] / 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                 x, y, w, h = skin.parameters.get("ChoicelistDash",(0, 0, 800, 25))
11                 res.append((eListboxPythonMultiContent.TYPE_TEXT, x, y, w, h, 0, RT_HALIGN_LEFT, "-"*200))
12         else:
13                 x, y, w, h = skin.parameters.get("ChoicelistName",(45, 0, 800, 25))
14                 res.append((eListboxPythonMultiContent.TYPE_TEXT, x, y, w, h, 0, RT_HALIGN_LEFT, text[0]))
15         
16                 png = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/buttons/key_" + key + ".png"))
17                 if png is not None:
18                         x, y, w, h = skin.parameters.get("ChoicelistIcon",(5, 0, 35, 25))
19                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, x, y, w, h, png))
20         
21         return res
22
23 class ChoiceList(MenuList):
24         def __init__(self, list, selection = 0, enableWrapAround=False):
25                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
26                 font = skin.fonts.get("ChoiceList", ("Regular", 20, 25))
27                 self.l.setFont(0, gFont(font[0], font[1]))
28                 self.l.setItemHeight(font[2])
29                 self.selection = selection
30
31         def postWidgetCreate(self, instance):
32                 MenuList.postWidgetCreate(self, instance)
33                 self.moveToIndex(self.selection)