fix deathscreen when opening wlan network list (ssid list) and the currently
[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                 self.onLayoutFinish.append(self.SelectionChanged)
27
28         def SelectionChanged(self):
29                 selection = self["list"].getCurrent()
30                 selection = selection and selection[3]
31                 arrow = self["arrowup"]
32                 sh_arrow = self["sh_arrowup"]
33
34                 if selection and selection[0][:3] == "sh_":
35                         sh_arrow.show()
36                 else:
37                         sh_arrow.hide()
38
39                 if selection and selection[0][:2] == "l_":
40                         self["long_key"].setText(_("Long Keypress"))
41                 else:
42                         self["long_key"].setText("")
43
44                 if selection is None:
45                         arrow.hide()
46                 else:
47                         arrow.moveTo(selection[1], selection[2], 1)
48                         arrow.startMoving()
49                         arrow.show()
50
51 class HelpableScreen:
52         def __init__(self):
53                 self["helpActions"] = ActionMap( [ "HelpActions" ],
54                         {
55                                 "displayHelp": self.showHelp,
56                         })
57
58         def showHelp(self):
59                 self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
60
61         def callHelpAction(self, *args):
62                 if len(args):
63                         (actionmap, context, action) = args
64                         actionmap.action(context, action)