X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/85f5c84f1e3e4d22fb1939751d39de03877b93d8..df7d9f3578c68b22c95ab9daa23bd0fa168f6d11:/lib/python/Components/Input.py diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py index d3b06612..f1a17d90 100644 --- a/lib/python/Components/Input.py +++ b/lib/python/Components/Input.py @@ -7,19 +7,33 @@ from enigma import eLabel from Tools.NumericalTextInput import NumericalTextInput class Input(HTMLComponent, GUIComponent, VariableText): - def __init__(self, text=""): + TEXT = 0 + PIN = 1 + NUMBER = 2 + + def __init__(self, text="", maxSize = False, type = TEXT): GUIComponent.__init__(self) VariableText.__init__(self) self.numericalTextInput = NumericalTextInput(self.right) + self.type = type + self.maxSize = maxSize self.currPos = 0 self.text = text self.update() def update(self): - self.setText(self.text[0:self.currPos] + "_" + self.text[self.currPos] + "_" + self.text[self.currPos + 1:]) + self.setMarkedPos(self.currPos) + text = self.text + if self.type == self.PIN: + text = "*" * len(self.text) + self.setText(text) + #self.setText(self.text[0:self.currPos] + "_" + self.text[self.currPos] + "_" + self.text[self.currPos + 1:]) + + def getText(self): + return self.text def createWidget(self, parent): - return eLabel(parent) + return eLabel(parent, self.currPos) def getSize(self): s = self.instance.calculateSize() @@ -28,19 +42,39 @@ class Input(HTMLComponent, GUIComponent, VariableText): def right(self): self.currPos += 1 if self.currPos == len(self.text): - self.text = self.text + " " + if self.maxSize: + self.currPos -= 1 + else: + self.text = self.text + " " + self.update() def left(self): self.currPos -= 1 self.update() + def up(self): + if self.text[self.currPos] == "9": + newNumber = "0" + else: + newNumber = str(int(self.text[self.currPos]) + 1) + self.text = self.text[0:self.currPos] + newNumber + self.text[self.currPos + 1:] + self.update() + + def down(self): + if self.text[self.currPos] == "0": + newNumber = "9" + else: + newNumber = str(int(self.text[self.currPos]) - 1) + self.text = self.text[0:self.currPos] + newNumber + self.text[self.currPos + 1:] + self.update() + def number(self, number): - self.text = self.text[0:self.currPos] + self.numericalTextInput.getKey(number) + self.text[self.currPos + 1:] + if self.type == self.TEXT: + newChar = self.numericalTextInput.getKey(number) + elif self.type == self.PIN or self.type == self.NUMBER: + newChar = str(number) + self.text = self.text[0:self.currPos] + newChar + self.text[self.currPos + 1:] + if self.type == self.PIN or self.type == self.NUMBER: + self.right() self.update() - - def show(self): - self.instance.show() - - def hide(self): - self.instance.hide() \ No newline at end of file