7bd52122306db9ec44b9194fffc5d9037b6cdbfc
[vuplus_dvbapp] / 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()
36                 selection = selection and selection[3]
37                 arrow = self["arrowup"]
38                 sh_arrow = self["sh_arrowup"]
39
40                 if selection and selection[0][:3] == "sh_":
41                         sh_arrow.show()
42                 else:
43                         sh_arrow.hide()
44
45                 if selection and selection[0][:2] == "l_":
46                         self["long_key"].setText(_("Long Keypress"))
47                 else:
48                         self["long_key"].setText("")
49
50                 if selection is None:
51                         arrow.hide()
52                 else:
53                         arrow.moveTo(selection[1], selection[2], 1)
54                         arrow.startMoving()
55                         arrow.show()
56
57 class HelpableScreen:
58         def __init__(self):
59                 self["helpActions"] = ActionMap( [ "HelpActions" ],
60                         {
61                                 "displayHelp": self.showHelp,
62                         })
63
64         def showHelp(self):
65                 self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
66
67         def callHelpAction(self, *args):
68                 if len(args):
69                         (actionmap, context, action) = args
70                         actionmap.action(context, action)