fix for older enigma2 versions
[enigma2.git] / lib / python / Screens / HelpMenu.py
1 from Screen import Screen
2 from Components.Pixmap import Pixmap, MovingPixmap
3 from Components.Label import Label
4 from Components.ActionMap import ActionMap
5 from Components.HelpMenuList import HelpMenuList
6 from Screens.Rc import Rc
7
8 class HelpMenu(Screen, Rc):
9         def __init__(self, session, list):
10                 Screen.__init__(self, session)
11                 self.onSelChanged = [ ]
12                 self["list"] = HelpMenuList(list, self.close)
13                 self["list"].onSelChanged.append(self.SelectionChanged)
14                 Rc.__init__(self)
15                 self["long_key"] = Label("")
16
17                 self["actions"] = ActionMap(["WizardActions"], 
18                 {
19                         "ok": self["list"].ok,
20                         "back": self.close,
21                 }, -1)
22
23                 self.onLayoutFinish.append(self.SelectionChanged)
24
25         def SelectionChanged(self):
26                 self.clearSelectedKeys()
27                 selection = self["list"].getCurrent()
28                 selection = selection[3]
29                 #arrow = self["arrowup"]
30                 print "selection:", selection
31
32                 longText = ""
33                 if selection and len(selection) > 1:
34                         if selection[1] == "SHIFT":
35                                 self.selectKey("SHIFT")
36                         elif selection[1] == "long":
37                                 longText = _("Long Keypress")
38                 self["long_key"].setText(longText)
39
40                 self.selectKey(selection[0])
41                 #if selection is None:
42                 print "select arrow"
43                 #       arrow.moveTo(selection[1], selection[2], 1)
44                 #       arrow.startMoving()
45                 #       arrow.show()
46
47 class HelpableScreen:
48         def __init__(self):
49                 self["helpActions"] = ActionMap( [ "HelpActions" ],
50                         {
51                                 "displayHelp": self.showHelp,
52                         })
53
54         def showHelp(self):
55                 self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
56
57         def callHelpAction(self, *args):
58                 if args:
59                         (actionmap, context, action) = args
60                         actionmap.action(context, action)