diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2005-11-18 02:53:40 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2005-11-18 02:53:40 +0000 |
| commit | bf7e40884d7add91e219e9e70e83988ae7752bd8 (patch) | |
| tree | 3e1048ad0c2b1e32a5c7b3b24dbcb59cf1a7045a /lib/python/Components | |
| parent | 81b381e1f5dd38ad1b80a3b3d96060b89a5fab6c (diff) | |
| download | enigma2-bf7e40884d7add91e219e9e70e83988ae7752bd8.tar.gz enigma2-bf7e40884d7add91e219e9e70e83988ae7752bd8.zip | |
add help stuff
Diffstat (limited to 'lib/python/Components')
| -rw-r--r-- | lib/python/Components/ActionMap.py | 28 | ||||
| -rw-r--r-- | lib/python/Components/HelpMenuList.py | 50 | ||||
| -rw-r--r-- | lib/python/Components/Makefile.am | 2 | ||||
| -rw-r--r-- | lib/python/Components/__init__.py | 2 |
4 files changed, 80 insertions, 2 deletions
diff --git a/lib/python/Components/ActionMap.py b/lib/python/Components/ActionMap.py index 2ed2fcc3..046a92d9 100644 --- a/lib/python/Components/ActionMap.py +++ b/lib/python/Components/ActionMap.py @@ -33,3 +33,31 @@ class NumberActionMap(ActionMap): 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)) diff --git a/lib/python/Components/HelpMenuList.py b/lib/python/Components/HelpMenuList.py new file mode 100644 index 00000000..34eb4119 --- /dev/null +++ b/lib/python/Components/HelpMenuList.py @@ -0,0 +1,50 @@ +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]) diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am index f49c7545..c2787d9c 100644 --- a/lib/python/Components/Makefile.am +++ b/lib/python/Components/Makefile.am @@ -9,4 +9,4 @@ install_PYTHON = \ 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 diff --git a/lib/python/Components/__init__.py b/lib/python/Components/__init__.py index ed74427a..0582a908 100644 --- a/lib/python/Components/__init__.py +++ b/lib/python/Components/__init__.py @@ -6,4 +6,4 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo", "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"] |
