(ralfk) display shifted keys and long keypresses in help window
[enigma2.git] / lib / python / Screens / HelpMenu.py
1 from Screen import Screen
2
3 from Components.Pixmap import *
4 from Components.Pixmap import Pixmap
5 from Components.Pixmap import MovingPixmap
6 from Components.Label import Label
7 from Components.Slider import Slider
8 from Components.ActionMap import ActionMap
9 from Components.HelpMenuList import HelpMenuList
10 import string
11 from xml.sax import make_parser
12 from xml.sax.handler import ContentHandler
13 from Components.MenuList import MenuList
14
15 class HelpMenu(Screen):
16         def __init__(self, session, list):
17                 Screen.__init__(self, session)
18                 self.onSelChanged = [ ]
19                 self["list"] = HelpMenuList(list, self.close)
20                 self["list"].onSelChanged.append(self.SelectionChanged)
21                 self["rc"] = Pixmap()
22                 self["arrowup"] = MovingPixmap()
23                 self["arrowup"].hide()
24                 self["sh_arrowup"] = Pixmap()
25                 self["sh_arrowup"].hide()
26                 self["long_key"] = Label("")
27
28                 self["actions"] = ActionMap(["WizardActions"], 
29                 {
30                         "ok": self["list"].ok,
31                         "back": self.close,
32                 }, -1)
33
34         def SelectionChanged(self):
35                 selection = self["list"].getCurrent()[3]
36                 arrow = self["arrowup"]
37                 sh_arrow = self["sh_arrowup"]
38
39                 if selection[0][:3] == "sh_":
40                         sh_arrow.show()
41                 else:
42                         sh_arrow.hide()
43
44                 if selection[0][:2] == "l_":
45                         self["long_key"].setText(_("Long Keypress"))
46                 else:
47                         self["long_key"].setText("")
48
49                 if selection is None:
50                         arrow.hide()
51                 else:
52                         arrow.moveTo(selection[1], selection[2], 1)
53                         arrow.startMoving()
54                         arrow.show()
55
56 class HelpableScreen:
57         def __init__(self):
58                 self["helpActions"] = ActionMap( [ "HelpActions" ],
59                         {
60                                 "displayHelp": self.showHelp,
61                         })
62
63         def showHelp(self):
64                 self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
65
66         def callHelpAction(self, *args):
67                 if len(args):
68                         (actionmap, context, action) = args
69                         actionmap.action(context, action)