+ def setList(self, l):
+ self.timer.stop()
+ self.__list = l
+ self.l.setList(self.__list)
+
+ if l is not None:
+ for x in l:
+ assert isinstance(x[1], ConfigElement), "entry in ConfigList " + str(x[1]) + " must be a ConfigElement"
+
+ def getList(self):
+ return self.__list
+
+ list = property(getList, setList)
+
+ def timeout(self):
+ self.handleKey(KEY_TIMEOUT)
+
+ def isChanged(self):
+ is_changed = False
+ for x in self.list:
+ is_changed |= x[1].isChanged()
+
+ return is_changed
+
+class ConfigListScreen:
+ def __init__(self, list, session = None, on_change = None):
+ self["config_actions"] = NumberActionMap(["SetupActions", "InputAsciiActions", "KeyboardInputActions"],
+ {
+ "gotAsciiCode": self.keyGotAscii,
+ "ok": self.keyOK,
+ "left": self.keyLeft,
+ "right": self.keyRight,
+ "home": self.keyHome,
+ "end": self.keyEnd,
+ "deleteForward": self.keyDelete,
+ "deleteBackward": self.keyBackspace,
+ "toggleOverwrite": self.keyToggleOW,
+ "1": self.keyNumberGlobal,
+ "2": self.keyNumberGlobal,
+ "3": self.keyNumberGlobal,
+ "4": self.keyNumberGlobal,
+ "5": self.keyNumberGlobal,
+ "6": self.keyNumberGlobal,
+ "7": self.keyNumberGlobal,
+ "8": self.keyNumberGlobal,
+ "9": self.keyNumberGlobal,
+ "0": self.keyNumberGlobal
+ }, -1) # to prevent left/right overriding the listbox
+
+ self["config"] = ConfigList(list, session = session)
+ if on_change is not None:
+ self.__changed = on_change
+ else:
+ self.__changed = lambda: None
+
+ def keyOK(self):
+ self["config"].handleKey(KEY_OK)
+
+ def keyLeft(self):
+ self["config"].handleKey(KEY_LEFT)
+ self.__changed()
+
+ def keyRight(self):
+ self["config"].handleKey(KEY_RIGHT)
+ self.__changed()
+
+ def keyHome(self):
+ self["config"].handleKey(KEY_HOME)
+ self.__changed()
+
+ def keyEnd(self):
+ self["config"].handleKey(KEY_END)
+ self.__changed()
+
+ def keyDelete(self):
+ self["config"].handleKey(KEY_DELETE)
+ self.__changed()
+
+ def keyBackspace(self):
+ self["config"].handleKey(KEY_BACKSPACE)
+ self.__changed()
+
+ def keyToggleOW(self):
+ self["config"].handleKey(KEY_TOGGLEOW)
+ self.__changed()
+
+ def keyGotAscii(self):
+ self["config"].handleKey(KEY_ASCII)
+ self.__changed()
+
+ def keyNumberGlobal(self, number):
+ self["config"].handleKey(KEY_0 + number)
+ self.__changed()
+
+ def saveAll(self):
+ for x in self["config"].list:
+ x[1].save()
+
+ # keySave and keyCancel are just provided in case you need them.
+ # you have to call them by yourself.
+ def keySave(self):
+ self.saveAll()
+ self.close()