add a small text input component
[openblackhole/openblackhole-enigma2.git] / lib / python / Components / Input.py
1 from HTMLComponent import *
2 from GUIComponent import *
3 from VariableText import *
4
5 from enigma import eLabel
6
7 from Tools.NumericalTextInput import NumericalTextInput
8
9 class Input(HTMLComponent, GUIComponent, VariableText):
10         def __init__(self, text=""):
11                 GUIComponent.__init__(self)
12                 VariableText.__init__(self)
13                 self.numericalTextInput = NumericalTextInput(self.right)
14                 self.currPos = 0
15                 self.text = text
16                 self.update()
17
18         def update(self):
19                 self.setText(self.text[0:self.currPos] + "_" + self.text[self.currPos] + "_" + self.text[self.currPos + 1:])
20         
21         def createWidget(self, parent):
22                 return eLabel(parent)
23         
24         def getSize(self):
25                 s = self.instance.calculateSize()
26                 return (s.width(), s.height())
27         
28         def right(self):
29                 self.currPos += 1
30                 if self.currPos == len(self.text):
31                         self.text = self.text + " "
32                 self.update()
33                 
34         def left(self):
35                 self.currPos -= 1
36                 self.update()
37                 
38         def number(self, number):
39                 self.text = self.text[0:self.currPos] + self.numericalTextInput.getKey(number) + self.text[self.currPos + 1:]
40                 self.update()
41
42         def show(self):
43                 self.instance.show()
44
45         def hide(self):
46                 self.instance.hide()