finished configuration in ScanSetup
[enigma2.git] / lib / python / Components / HelpMenuList.py
1 from GUIComponent import *
2
3 from enigma import eListboxPythonMultiContent, eListbox, gFont
4
5 from Tools.KeyBindings import queryKeyBinding, getKeyDescription
6
7 # [ ( actionmap, context, [(action, help), (action, help), ...] ), (actionmap, ... ), ... ]
8
9 class HelpMenuList(GUIComponent):
10         def __init__(self, list, callback):
11                 GUIComponent.__init__(self)
12                 
13                 self.l = eListboxPythonMultiContent()
14                 self.callback = callback
15                 
16                 l = [ ]
17                 for (actionmap, context, actions) in list:
18                         for (action, help) in actions:
19                                 entry = [ ]
20                                 
21                                 entry.append( (actionmap, context, action) )
22                                 buttons = queryKeyBinding(context, action)
23                                 buttonstring = ""
24         
25                                 first = True
26                                 for n in buttons:
27                                         name = getKeyDescription(n)
28                                         if name is None:
29                                                 continue
30
31                                         if not first:
32                                                 buttonstring += ", or "
33
34                                         first = False
35                                         buttonstring += name
36
37                                 if not first:
38                                         buttonstring = "You can also press " + buttonstring + "."
39
40                                 entry.append( (0, 0, 200, 36, 0, 0, help) )
41                                 entry.append( (0, 40, 200, 20, 1, 0, buttonstring) )
42                                 
43                                 l.append(entry)
44                 
45                 self.l.setList(l)
46                 
47                 self.l.setFont(0, gFont("Arial", 36))
48                 self.l.setFont(1, gFont("Arial", 18))
49         
50         def GUIcreate(self, parent):
51                 self.instance = eListbox(parent)
52                 self.instance.setContent(self.l)
53                 self.instance.setItemHeight(75)
54         
55         def GUIdelete(self):
56                 self.instance.setContent(None)
57                 self.instance = None
58
59         def ok(self):
60                 # a list entry has a "private" tuple as first entry...
61                 l = self.l.getCurrentSelection()[0]
62                 
63                 # ...containing (Actionmap, Context, Action).
64                 # we returns this tuple to the callback.
65                 self.callback(l[0], l[1], l[2])