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, helplist, 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 helplist:
19 for (action, help) in actions:
20 buttons = queryKeyBinding(context, action)
22 # do not display entries which are not accessible from keys
30 (name, flags) = (getKeyDescription(n[0]), n[1])
34 if flags & 8: # for long keypresses, prepend l_ into the key name.
35 name = (name[0], "long")
37 entry = [ (actionmap, context, action, name ) ]
39 if isinstance(help, list):
40 self.extendedHelp = True
41 print "extendedHelpEntry found"
43 (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 26, 0, 0, help[0]),
44 (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: