</map>
+ <map context="HelpActions">
+ <key id="KEY_HELP" mapto="displayHelp" flags="m" />
+ </map>
+
<map context="ShortcutActions">
<key id="KEY_F1" mapto="red" flags="mr" />
<key id="KEY_F2" mapto="yellow" flags="mr" />
<widget name="end" position="508,150" size="72,35" font="Arial;25" />
<widget name="apply" position="10,240" size="250,35" />
</screen>
+ <screen name="HelpMenu" flags="wfNoBorder" position="0,0" size="720,576" title="Menu">
+ <widget name="list" position="100,100" size="550,375" />
+ </screen>
<screen name="MessageBox" position="0,300" size="720,10" title="Message">
<widget name="text" position="0,0" size="650,0" font="Arial;22" />
<applet type="onLayoutFinish">
return 1
else:
return ActionMap.action(self, contexts, action)
+
+class HelpableActionMap(ActionMap):
+ """An Actionmap which automatically puts the actions into the helpList.
+
+ Note that you can only use ONE context here!"""
+
+ # sorry for this complicated code.
+ # it's not more than converting a "documented" actionmap
+ # (where the values are possibly (function, help)-tuples)
+ # into a "classic" actionmap, where values are just functions.
+ # the classic actionmap is then passed to the ActionMap constructor,
+ # the collected helpstrings (with correct context, action) is
+ # added to the screen's "helpList", which will be picked up by
+ # the "HelpableScreen".
+ def __init__(self, parent, context, actions = { }, prio=0):
+ alist = [ ]
+ adict = { }
+ for (action, funchelp) in actions.iteritems():
+ # check if this is a tuple
+ if type(funchelp) is type(()):
+ alist.append((action, funchelp[1]))
+ adict[action] = funchelp[0]
+ else:
+ adict[action] = funchelp
+
+ ActionMap.__init__(self, [context], adict, prio)
+
+ parent.helpList.append((self, context, alist))
--- /dev/null
+from GUIComponent import *
+
+from enigma import eListboxPythonMultiContent, eListbox, gFont
+
+# [ ( actionmap, context, [(action, help), (action, help), ...] ), (actionmap, ... ), ... ]
+
+class HelpMenuList(GUIComponent):
+ def __init__(self, list, callback):
+ GUIComponent.__init__(self)
+
+ self.l = eListboxPythonMultiContent()
+ self.callback = callback
+
+ l = [ ]
+ for (actionmap, context, actions) in list:
+
+ print "actionmap:" + str(actionmap)
+ print "context: " + str(context)
+ print "actions: " + str(actions)
+
+ for (action, help) in actions:
+ entry = [ ]
+
+ entry.append( (actionmap, context, action) )
+ entry.append( (0, 36, 200, 20, 1, 0, "you can also press a secret button") )
+ entry.append( (0, 0, 200, 36, 0, 0, help) )
+
+ l.append(entry)
+
+ self.l.setList(l)
+
+ self.l.setFont(0, gFont("Arial", 36))
+ self.l.setFont(1, gFont("Arial", 18))
+
+ def GUIcreate(self, parent):
+ self.instance = eListbox(parent)
+ self.instance.setContent(self.l)
+ self.instance.setItemHeight(75)
+
+ def GUIdelete(self):
+ self.instance.setContent(None)
+ self.instance = None
+
+ def ok(self):
+ # a list entry has a "private" tuple as first entry...
+ l = self.l.getCurrentSelection()[0]
+
+ # ...containing (Actionmap, Context, Action).
+ # we returns this tuple to the callback.
+ self.callback(l[0], l[1], l[2])
GUIComponent.py MenuList.py TextInput.py __init__.py MovieList.py \
InputDevice.py ServicePosition.py SetupDevices.py Harddisk.py \
AVSwitch.py Network.py RFmod.py DiskInfo.py NimManager.py Lcd.py \
- EpgList.py ScrollLabel.py Timezones.py Language.py
+ EpgList.py ScrollLabel.py Timezones.py Language.py HelpMenuList.py
"components", "config", "TimerList", "TimeInput", "MovieList",
"InputDevice", "ServicePosition", "IPAddress", "VariableIP", "IPGateway",
"IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry",
- "Lcd", "EpgList" "ScrollLabel", "Timezones"]
+ "Lcd", "EpgList" "ScrollLabel", "Timezones", "HelpMenuList"]
--- /dev/null
+from Screen import Screen
+
+from Components.ActionMap import ActionMap
+from Components.HelpMenuList import HelpMenuList
+
+class HelpMenu(Screen):
+ def __init__(self, session, list):
+ Screen.__init__(self, session)
+
+ self["list"] = HelpMenuList(list, self.close)
+ self["actions"] = ActionMap(["OkCancelActions"],
+ {
+ "cancel": self.close,
+ "ok": self["list"].ok,
+ })
+
+class HelpableScreen:
+ def __init__(self):
+ self["helpActions"] = ActionMap( [ "HelpActions" ],
+ {
+ "displayHelp": self.showHelp,
+ })
+
+ def showHelp(self):
+ self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
+
+ def callHelpAction(self, *args):
+ if len(args):
+ (actionmap, context, action) = args
+ actionmap.action(context, action)
InfoBarEPG, InfoBarEvent, InfoBarServiceName, InfoBarPVR, InfoBarInstantRecord, \
InfoBarAudioSelection
+from Screens.HelpMenu import HelpableScreen, HelpMenu
+
from enigma import *
import time
class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
- InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection):
+ InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection,
+ HelpableScreen):
def __init__(self, session):
Screen.__init__(self, session)
"showMovies": self.showMovies,
})
- for x in InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
- InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
- InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection:
+ for x in HelpableScreen, \
+ InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
+ InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
+ InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection:
x.__init__(self)
+ self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
+
self["CurrentTime"] = Clock()
def showMovies(self):
self.session.openWithCallback(self.movieSelected, MovieSelection)
-
+
def movieSelected(self, service):
if service is not None:
self.session.open(MoviePlayer, service)
from Screen import Screen
-from Components.ActionMap import ActionMap
+from Components.ActionMap import ActionMap, HelpableActionMap
from Components.ActionMap import NumberActionMap
from Components.Label import Label
from Components.config import configfile, configsequencearg
#instantiate forever
self.servicelist = self.session.instantiateDialog(ChannelSelection)
- self["ChannelSelectActions"] = ActionMap( ["InfobarChannelSelection"],
+ self["ChannelSelectActions"] = HelpableActionMap(self, "InfobarChannelSelection",
{
"switchChannelUp": self.switchChannelUp,
"switchChannelDown": self.switchChannelDown,
- "zapUp": self.zapUp,
- "zapDown": self.zapDown,
+ "zapUp": (self.zapUp, _("next channel")),
+ "zapDown": (self.zapDown, _("previous channel")),
})
def switchChannelUp(self):
class InfoBarEPG:
""" EPG - Opens an EPG list when the showEPGList action fires """
def __init__(self):
- self["EPGActions"] = ActionMap( [ "InfobarEPGActions" ],
+ self["EPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
{
- "showEPGList": self.showEPGList,
+ "showEPGList": (self.showEPGList, _("show EPG...")),
})
def showEPGList(self):
MovieSelection.py Setup.py About.py HarddiskSetup.py FixedMenu.py \
Satconfig.py ScanSetup.py NetworkSetup.py Ci.py TimerEntry.py Volume.py \
EpgSelection.py EventView.py Mute.py Standby.py ServiceInfo.py \
- AudioSelection.py InfoBarGenerics.py __init__.py
+ AudioSelection.py InfoBarGenerics.py HelpMenu.py __init__.py
self.session = session
GUISkin.__init__(self)
+ # in order to support screens *without* a help,
+ # we need the list in every screen. how ironic.
+ self.helpList = [ ]
+
def execBegin(self):
# assert self.session == None, "a screen can only exec one per time"
# self.session = session
# never call this directly - it will be called from the session!
def doClose(self):
+ # fixup circular references
+ del self.helpList
GUISkin.close(self)
del self.session
"TimerEdit", "Setup", "HarddiskSetup", "FixedMenu",
"Satconfig", "Scanconfig", "Ci.py", "Volume.py", "Mute.py",
"EpgSelection", "EventView", "Standby", "ServiceInfo",
- "AudioSelection", "InfoBarGenerics"]
+ "AudioSelection", "InfoBarGenerics", "HelpMenu"]