cleanup some imports
[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
7 class HelpMenu(Screen):
8         def __init__(self, session, list):
9                 Screen.__init__(self, session)
10                 self.onSelChanged = [ ]
11                 self["list"] = HelpMenuList(list, self.close)
12                 self["list"].onSelChanged.append(self.SelectionChanged)
13                 self["rc"] = Pixmap()
14                 self["arrowup"] = MovingPixmap()
15                 self["arrowup"].hide()
16                 self["sh_arrowup"] = Pixmap()
17                 self["sh_arrowup"].hide()
18                 self["long_key"] = Label("")
19
20                 self["actions"] = ActionMap(["WizardActions"], 
21                 {
22                         "ok": self["list"].ok,
23                         "back": self.close,
24                 }, -1)
25
26         def SelectionChanged(self):
27                 selection = self["list"].getCurrent()
28                 selection = selection and selection[3]
29                 arrow = self["arrowup"]
30                 sh_arrow = self["sh_arrowup"]
31
32                 if selection and selection[0][:3] == "sh_":
33                         sh_arrow.show()
34                 else:
35                         sh_arrow.hide()
36
37                 if selection and selection[0][:2] == "l_":
38                         self["long_key"].setText(_("Long Keypress"))
39                 else:
40                         self["long_key"].setText("")
41
42                 if selection is None:
43                         arrow.hide()
44                 else:
45                         arrow.moveTo(selection[1], selection[2], 1)
46                         arrow.startMoving()
47                         arrow.show()
48
49 class HelpableScreen:
50         def __init__(self):
51                 self["helpActions"] = ActionMap( [ "HelpActions" ],
52                         {
53                                 "displayHelp": self.showHelp,
54                         })
55
56         def showHelp(self):
57                 self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
58
59         def callHelpAction(self, *args):
60                 if len(args):
61                         (actionmap, context, action) = args
62                         actionmap.action(context, action)