From 85f5c84f1e3e4d22fb1939751d39de03877b93d8 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Thu, 19 Jan 2006 02:18:21 +0000 Subject: add a small text input component --- lib/python/Components/Input.py | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 lib/python/Components/Input.py (limited to 'lib/python/Components/Input.py') diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py new file mode 100644 index 00000000..d3b06612 --- /dev/null +++ b/lib/python/Components/Input.py @@ -0,0 +1,46 @@ +from HTMLComponent import * +from GUIComponent import * +from VariableText import * + +from enigma import eLabel + +from Tools.NumericalTextInput import NumericalTextInput + +class Input(HTMLComponent, GUIComponent, VariableText): + def __init__(self, text=""): + GUIComponent.__init__(self) + VariableText.__init__(self) + self.numericalTextInput = NumericalTextInput(self.right) + 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:]) + + def createWidget(self, parent): + return eLabel(parent) + + def getSize(self): + s = self.instance.calculateSize() + return (s.width(), s.height()) + + def right(self): + self.currPos += 1 + if self.currPos == len(self.text): + self.text = self.text + " " + self.update() + + def left(self): + 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:] + self.update() + + def show(self): + self.instance.show() + + def hide(self): + self.instance.hide() \ No newline at end of file -- cgit v1.2.3