1 from HTMLComponent import *
2 from GUIComponent import *
3 from VariableText import *
5 from enigma import eLabel, isUTF8, convertUTF8DVB, convertDVBUTF8
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.numericalTextInput = NumericalTextInput(self.right)
20 self.maxSize = maxSize
27 self.setMarkedPos(self.currPos)
28 if self.type == self.PIN:
29 self.message = "*" * len(self.Text)
31 self.message = convertDVBUTF8(self.Text, self.table)
33 self.instance.setText(self.message)
35 def setText(self, text):
40 self.Text = convertUTF8DVB(text, self.table)
46 return convertDVBUTF8(self.Text, self.table)
48 def createWidget(self, parent):
49 return eLabel(parent, self.currPos)
52 s = self.instance.calculateSize()
53 return (s.width(), s.height())
57 if self.currPos == len(self.Text):
61 self.Text = self.Text + " "
70 if self.Text[self.currPos] == "9" or self.Text[self.currPos] == " ":
73 newNumber = str(int(self.Text[self.currPos]) + 1)
74 self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:]
78 if self.Text[self.currPos] == "0" or self.Text[self.currPos] == " ":
81 newNumber = str(int(self.Text[self.currPos]) - 1)
82 self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:]
90 self.currPos = len(self.Text) - 1
94 if self.currPos == len(self.Text) - 1:
95 self.Text=self.Text+ " "
98 self.Text = self.Text[0:self.currPos] + " " + self.Text[self.currPos:]
102 self.Text = self.Text[:self.currPos] + self.Text[self.currPos + 1:]
105 def toggleOverwrite(self):
106 if self.overwrite==1:
112 def deleteBackward(self):
113 self.Text = self.Text[:self.currPos - 1] + self.Text[self.currPos:]
117 def handleAscii(self, code):
119 if self.overwrite==1:
120 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
122 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos:]
125 def number(self, number):
126 if self.type == self.TEXT:
127 newChar = self.numericalTextInput.getKey(number)
128 elif self.type == self.PIN or self.type == self.NUMBER:
129 newChar = str(number)
130 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
131 if self.type == self.PIN or self.type == self.NUMBER: