1 from GUIComponent import GUIComponent
3 from enigma import eListboxPythonMultiContent, eListbox, gFont
4 from Tools.KeyBindings import queryKeyBinding, getKeyDescription
7 # [ ( actionmap, context, [(action, help), (action, help), ...] ), (actionmap, ... ), ... ]
9 class HelpMenuList(GUIComponent):
10 def __init__(self, list, callback):
11 GUIComponent.__init__(self)
12 self.onSelChanged = [ ]
13 self.l = eListboxPythonMultiContent()
14 self.callback = callback
15 self.extendedHelp = False
18 for (actionmap, context, actions) in list:
19 for (action, help) in actions:
22 buttons = queryKeyBinding(context, action)
24 # do not display entries which are not accessible from keys
32 (name, flags) = (getKeyDescription(n[0]), n[1])
36 if flags & 8: # for long keypresses, prepend l_ into the key name.
37 name = (name[0], "long")
39 entry.append( (actionmap, context, action, name ) )
41 if type(help).__name__== 'list':
42 self.extendedHelp = True
43 print "extendedHelpEntry found"
44 entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 26, 0, 0, help[0]) )
45 entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 28, 400, 20, 1, 0, help[1]) )
47 entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 28, 0, 0, help) )
52 if self.extendedHelp is True:
53 self.l.setFont(0, gFont("Regular", 24))
54 self.l.setFont(1, gFont("Regular", 18))
55 self.l.setItemHeight(50)
57 self.l.setFont(0, gFont("Regular", 24))
58 self.l.setItemHeight(38)
61 # a list entry has a "private" tuple as first entry...
65 # ...containing (Actionmap, Context, Action, keydata).
66 # we returns this tuple to the callback.
67 self.callback(l[0], l[1], l[2])
70 sel = self.l.getCurrentSelection()
75 def postWidgetCreate(self, instance):
76 instance.setContent(self.l)
77 instance.selectionChanged.get().append(self.selectionChanged)
79 def preWidgetRemove(self, instance):
80 instance.setContent(None)
81 instance.selectionChanged.get().remove(self.selectionChanged)
83 def selectionChanged(self):
84 for x in self.onSelChanged: