X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/ed40f6f85c9c07c3c1224ae20601082c0309a631..b3813095d2b2d9b546eeb075de3bdb78e48987e6:/lib/python/Screens/ChoiceBox.py diff --git a/lib/python/Screens/ChoiceBox.py b/lib/python/Screens/ChoiceBox.py index 37729887..7c8b1427 100644 --- a/lib/python/Screens/ChoiceBox.py +++ b/lib/python/Screens/ChoiceBox.py @@ -1,16 +1,20 @@ from Screens.Screen import Screen -from Screens.MessageBox import MessageBox from Components.ActionMap import NumberActionMap from Components.Label import Label -from Components.MenuList import MenuList from Components.ChoiceList import ChoiceEntryComponent, ChoiceList +from Components.Sources.StaticText import StaticText class ChoiceBox(Screen): - def __init__(self, session, title = "", list = [], keys = None, selection = 0): + def __init__(self, session, title = "", list = [], keys = None, selection = 0, skin_name = []): Screen.__init__(self, session) + if isinstance(skin_name, str): + skin_name = [skin_name] + self.skinName = skin_name + ["ChoiceBox"] + self["text"] = Label(title) self.list = [] + self.summarylist = [] if keys is None: self.__keys = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "red", "green", "yellow", "blue" ] + (len(list) - 10) * [""] else: @@ -23,8 +27,11 @@ class ChoiceBox(Screen): self.list.append(ChoiceEntryComponent(key = strpos, text = x)) if self.__keys[pos] != "": self.keymap[self.__keys[pos]] = list[pos] + self.summarylist.append((self.__keys[pos],x[0])) pos += 1 self["list"] = ChoiceList(list = self.list, selection = selection) + self["summary_list"] = StaticText() + self.updateSummary() self["actions"] = NumberActionMap(["WizardActions", "InputActions", "ColorActions", "DirectionActions"], { @@ -58,6 +65,7 @@ class ChoiceBox(Screen): if len(self["list"].list) > 0: while 1: self["list"].instance.moveSelection(self["list"].instance.moveUp) + self.updateSummary(self["list"].l.getCurrentSelectionIndex()) if self["list"].l.getCurrentSelection()[0][0] != "--" or self["list"].l.getCurrentSelectionIndex() == 0: break @@ -65,6 +73,7 @@ class ChoiceBox(Screen): if len(self["list"].list) > 0: while 1: self["list"].instance.moveSelection(self["list"].instance.moveDown) + self.updateSummary(self["list"].l.getCurrentSelectionIndex()) if self["list"].l.getCurrentSelection()[0][0] != "--" or self["list"].l.getCurrentSelectionIndex() == len(self["list"].list) - 1: break @@ -74,7 +83,11 @@ class ChoiceBox(Screen): # runs the current selected entry def go(self): - self.goEntry(self["list"].l.getCurrentSelection()[0]) + cursel = self["list"].l.getCurrentSelection() + if cursel: + self.goEntry(cursel[0]) + else: + self.cancel() # runs a specific entry def goEntry(self, entry): @@ -104,5 +117,18 @@ class ChoiceBox(Screen): def keyBlue(self): self.goKey("blue") + def updateSummary(self, curpos=0): + pos = 0 + summarytext = "" + for entry in self.summarylist: + if pos > curpos-2 and pos < curpos+5: + if pos == curpos: + summarytext += ">" + else: + summarytext += entry[0] + summarytext += ' ' + entry[1] + '\n' + pos += 1 + self["summary_list"].setText(summarytext) + def cancel(self): self.close(None)