1 from HTMLComponent import *
2 from GUIComponent import *
3 from VariableText import *
5 from enigma import eLabel
7 from Tools.NumericalTextInput import NumericalTextInput
9 class Input(VariableText, HTMLComponent, GUIComponent):
14 def __init__(self, text="", maxSize = False, type = TEXT):
15 GUIComponent.__init__(self)
16 VariableText.__init__(self)
18 self.maxSize = maxSize
21 self.numericalTextInput = NumericalTextInput(self.right)
25 self.setMarkedPos(self.currPos)
26 if self.type == self.PIN:
27 self.text = "*" * len(self.Text)
29 self.text = self.Text.encode("utf-8")
31 def setText(self, text):
37 self.Text = text.decode("utf-8")
38 except UnicodeDecodeError:
44 return self.Text.encode("utf-8")
46 def createWidget(self, parent):
47 return eLabel(parent, self.currPos)
50 s = self.instance.calculateSize()
51 return (s.width(), s.height())
55 if self.currPos == len(self.Text):
59 self.Text = self.Text + " "
68 if self.Text[self.currPos] == "9" or self.Text[self.currPos] == " ":
71 newNumber = str(int(self.Text[self.currPos]) + 1)
72 self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:]
76 if self.Text[self.currPos] == "0" or self.Text[self.currPos] == " ":
79 newNumber = str(int(self.Text[self.currPos]) - 1)
80 self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:]
88 self.currPos = len(self.Text) - 1
92 if self.currPos == len(self.Text) - 1:
93 self.Text=self.Text+ " "
96 self.Text = self.Text[0:self.currPos] + " " + self.Text[self.currPos:]
100 self.Text = self.Text[:self.currPos] + self.Text[self.currPos + 1:]
103 def toggleOverwrite(self):
104 if self.overwrite==1:
110 def deleteBackward(self):
111 self.Text = self.Text[:self.currPos - 1] + self.Text[self.currPos:]
115 def handleAscii(self, code):
116 newChar = unichr(code)
117 if self.overwrite==1:
118 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
120 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos:]
123 def number(self, number):
124 if self.type == self.TEXT:
125 newChar = self.numericalTextInput.getKey(number)
126 elif self.type == self.PIN or self.type == self.NUMBER:
127 newChar = str(number)
128 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
129 if self.type == self.PIN or self.type == self.NUMBER: