diff options
| author | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-10-10 03:00:49 +0000 |
|---|---|---|
| committer | Stefan Pluecken <stefan.pluecken@multimedia-labs.de> | 2006-10-10 03:00:49 +0000 |
| commit | 01abec53c6856c24666967ee51d25d09fc6b8863 (patch) | |
| tree | 19d7bbbd3ce91544c36ba2fc38af83c877d82b01 /lib/python/Screens/InputBox.py | |
| parent | ce7847e4311c165e5441ac2dbb0d9cdbe95b68b9 (diff) | |
| download | enigma2-01abec53c6856c24666967ee51d25d09fc6b8863.tar.gz enigma2-01abec53c6856c24666967ee51d25d09fc6b8863.zip | |
add parental control (still somehow buggy and some minor features missing... don't trust it
yet to protect your children)
Diffstat (limited to 'lib/python/Screens/InputBox.py')
| -rw-r--r-- | lib/python/Screens/InputBox.py | 51 |
1 files changed, 50 insertions, 1 deletions
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 |
