X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/ce7847e4311c165e5441ac2dbb0d9cdbe95b68b9..01abec53c6856c24666967ee51d25d09fc6b8863:/lib/python/Screens/InputBox.py diff --git a/lib/python/Screens/InputBox.py b/lib/python/Screens/InputBox.py index 558cbc01..e73215c3 100644 --- a/lib/python/Screens/InputBox.py +++ b/lib/python/Screens/InputBox.py @@ -5,15 +5,17 @@ from Components.ActionMap import NumberActionMap from Components.Label import Label from Components.Input import Input from Components.GUIComponent import * +from Tools.BoundFunction import boundFunction import os class InputBox(Screen): - def __init__(self, session, title = "", **kwargs): + def __init__(self, session, title = "", windowTitle = _("Input"), **kwargs): Screen.__init__(self, session) self["text"] = Label(title) self["input"] = Input(**kwargs) + self.onShown.append(boundFunction(self.setTitle, windowTitle)) self["actions"] = NumberActionMap(["WizardActions", "InputBoxActions", "InputAsciiActions", "KeyboardInputActions"], { @@ -85,3 +87,50 @@ class InputBox(Screen): def keyInsert(self): self["input"].toggleOverwrite() + +class PinInput(InputBox): + def __init__(self, session, service = "", tries = 1, pinList = [], *args, **kwargs): + InputBox.__init__(self, session = session, text="9876", maxSize=True, type=Input.PIN, *args, **kwargs) + + self.showTries = True + if tries == 1: + self.showTries = False + + self.pinList = pinList + self["service"] = Label(service) + + self["tries"] = Label("") + self.onShown.append(boundFunction(self.setTries, tries)) + + def keyNumberGlobal(self, number): + if self["input"].currPos == len(self["input"]) - 1: + InputBox.keyNumberGlobal(self, number) + self.go() + else: + InputBox.keyNumberGlobal(self, number) + + def checkPin(self, pin): + if pin is not None and int(pin) in self.pinList: + return True + return False + + def go(self): + if self.checkPin(self["input"].getText()): + self.close((True, self.tries)) + else: + self.keyHome() + self.setTries(self.tries - 1) + if self.tries == 0: + self.close((False, self.tries)) + else: + pass + + def cancel(self): + rcinput = eRCInput.getInstance() + rcinput.setKeyboardMode(rcinput.kmNone) + self.close((None, self.tries)) + + def setTries(self, tries): + self.tries = tries + if self.showTries: + self["tries"].setText(_("Tries left:") + " " + str(tries)) \ No newline at end of file