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)
17 self.numericalTextInput = NumericalTextInput(self.right)
19 self.maxSize = maxSize
25 self.setMarkedPos(self.currPos)
26 if self.type == self.PIN:
27 self.message = "*" * len(self.Text)
29 self.message = convertDVBUTF8(self.Text, 0)
31 self.instance.setText(self.message)
33 def setText(self, text):
37 self.Text = convertUTF8DVB(text, 0)
43 return convertDVBUTF8(self.Text, 0)
45 def createWidget(self, parent):
46 return eLabel(parent, self.currPos)
49 s = self.instance.calculateSize()
50 return (s.width(), s.height())
54 if self.currPos == len(self.Text):
58 self.Text = self.Text + " "
67 if self.Text[self.currPos] == "9" or self.Text[self.currPos] == " ":
70 newNumber = str(int(self.Text[self.currPos]) + 1)
71 self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:]
75 if self.Text[self.currPos] == "0" or self.Text[self.currPos] == " ":
78 newNumber = str(int(self.Text[self.currPos]) - 1)
79 self.Text = self.Text[0:self.currPos] + newNumber + self.Text[self.currPos + 1:]
83 self.Text = self.Text[:self.currPos] + self.Text[self.currPos + 1:]
86 def handleAscii(self, code):
88 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
91 def number(self, number):
92 if self.type == self.TEXT:
93 newChar = self.numericalTextInput.getKey(number)
94 elif self.type == self.PIN or self.type == self.NUMBER:
96 self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
97 if self.type == self.PIN or self.type == self.NUMBER: