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, NumericalTextInput):
14 def __init__(self, text="", maxSize = False, type = TEXT):
15 NumericalTextInput.__init__(self, self.right)
16 GUIComponent.__init__(self)
17 VariableText.__init__(self)
19 self.maxSize = maxSize
28 self.setMarkedPos(self.currPos)
29 if self.type == self.PIN:
30 self.text = "*" * len(self.Text)
32 self.text = self.Text.encode("utf-8")
34 def setText(self, text):
40 self.Text = text.decode("utf-8")
41 except UnicodeDecodeError:
47 return self.Text.encode("utf-8")
49 def createWidget(self, parent):
50 return eLabel(parent, self.currPos)
53 s = self.instance.calculateSize()
54 return (s.width(), s.height())
58 if self.currPos == len(self.Text):
62 self.Text = self.Text + " "
71 if self.Text[self.currPos] == "9" or self.Text[self.currPos] == " ":
74 newNumber = str(int(self.Text[self.currPos]) + 1)
75 self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:]
79 if self.Text[self.currPos] == "0" or self.Text[self.currPos] == " ":
82 newNumber = str(int(self.Text[self.currPos]) - 1)
83 self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:]
91 self.currPos = len(self.Text) - 1
95 if self.currPos == len(self.Text) - 1:
96 self.Text=self.Text+ " "
99 self.Text = self.Text[0:self.currPos] + " " + self.Text[self.currPos:]
103 self.Text = self.Text[:self.currPos] + self.Text[self.currPos + 1:]
106 def toggleOverwrite(self):
107 if self.overwrite==1:
113 def deleteBackward(self):
114 self.Text = self.Text[:self.currPos - 1] + self.Text[self.currPos:]
118 def handleAscii(self, code):
119 newChar = unichr(code)
120 if self.overwrite==1:
121 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
123 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos:]
126 def number(self, number):
127 if self.type == self.TEXT:
128 newChar = self.getKey(number)
129 elif self.type == self.PIN or self.type == self.NUMBER:
130 newChar = str(number)
131 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
132 if self.type == self.PIN or self.type == self.NUMBER: