add turkish language, thanks to translator\!
[enigma2.git] / lib / python / Components / ChoiceList.py
1 from HTMLComponent import *
2 from GUIComponent import *
3
4 from MenuList import MenuList
5
6 from Tools.Directories import *
7
8 from enigma import *
9
10 RT_HALIGN_LEFT = 0
11 RT_HALIGN_RIGHT = 1
12 RT_HALIGN_CENTER = 2
13 RT_HALIGN_BLOCK = 4
14
15 RT_VALIGN_TOP = 0
16 RT_VALIGN_CENTER = 8
17 RT_VALIGN_BOTTOM = 16
18
19 def ChoiceEntryComponent(key, text):
20         res = [ text ]
21         if text[0] == "--":
22                 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 00, 800, 25, 0, RT_HALIGN_LEFT, "-"*200))
23         else:
24                 res.append((eListboxPythonMultiContent.TYPE_TEXT, 32, 00, 800, 25, 0, RT_HALIGN_LEFT, text[0]))
25         
26                 png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "key_" + key + "-fs8.png"))
27                 if png is not None:
28                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 30, 20, png))
29         
30         return res
31
32 class ChoiceList(MenuList, HTMLComponent, GUIComponent):
33         def __init__(self, list, selection = 0):
34                 GUIComponent.__init__(self)
35                 self.l = eListboxPythonMultiContent()
36                 self.list = list
37                 self.l.setList(list)
38                 self.l.setFont(0, gFont("Regular", 20))
39                 self.selection = selection
40
41         GUI_WIDGET = eListbox
42                 
43         def postWidgetCreate(self, instance):
44                 instance.setContent(self.l)
45                 instance.setItemHeight(25)
46                 self.moveToIndex(self.selection)