add help stuff
[enigma2.git] / lib / python / Components / HelpMenuList.py
1 from GUIComponent import *
2
3 from enigma import eListboxPythonMultiContent, eListbox, gFont
4
5 # [ ( actionmap, context, [(action, help), (action, help), ...] ), (actionmap, ... ), ... ]
6
7 class HelpMenuList(GUIComponent):
8         def __init__(self, list, callback):
9                 GUIComponent.__init__(self)
10                 
11                 self.l = eListboxPythonMultiContent()
12                 self.callback = callback
13                 
14                 l = [ ]
15                 for (actionmap, context, actions) in list:
16                         
17                         print "actionmap:"  + str(actionmap)
18                         print "context: " + str(context)
19                         print "actions: " + str(actions)
20                         
21                         for (action, help) in actions:
22                                 entry = [ ]
23                                 
24                                 entry.append( (actionmap, context, action) )
25                                 entry.append( (0, 36, 200, 20, 1, 0, "you can also press a secret button") )
26                                 entry.append( (0, 0, 200, 36, 0, 0, help) )
27                                 
28                                 l.append(entry)
29                 
30                 self.l.setList(l)
31                 
32                 self.l.setFont(0, gFont("Arial", 36))
33                 self.l.setFont(1, gFont("Arial", 18))
34         
35         def GUIcreate(self, parent):
36                 self.instance = eListbox(parent)
37                 self.instance.setContent(self.l)
38                 self.instance.setItemHeight(75)
39         
40         def GUIdelete(self):
41                 self.instance.setContent(None)
42                 self.instance = None
43
44         def ok(self):
45                 # a list entry has a "private" tuple as first entry...
46                 l = self.l.getCurrentSelection()[0]
47                 
48                 # ...containing (Actionmap, Context, Action).
49                 # we returns this tuple to the callback.
50                 self.callback(l[0], l[1], l[2])