from GUIComponent import *
from VariableText import *
-from enigma import eLabel, isUTF8, convertUTF8DVB, convertDVBUTF8
+from enigma import eLabel
from Tools.NumericalTextInput import NumericalTextInput
class Input(VariableText, HTMLComponent, GUIComponent):
TEXT = 0
PIN = 1
- NUMBER = 2
+ NUMBER = 2
def __init__(self, text="", maxSize = False, type = TEXT):
GUIComponent.__init__(self)
VariableText.__init__(self)
- self.table = 0
- self.numericalTextInput = NumericalTextInput(self.right)
self.type = type
self.maxSize = maxSize
self.currPos = 0
- self.Text = text
self.overwrite = 0
- self.update()
+ self.numericalTextInput = NumericalTextInput(self.right)
+ self.setText(text)
def update(self):
self.setMarkedPos(self.currPos)
if self.type == self.PIN:
- self.message = "*" * len(self.Text)
+ self.text = "*" * len(self.Text)
else:
- self.message = convertDVBUTF8(self.Text, self.table)
- if self.instance:
- self.instance.setText(self.message)
+ self.text = self.Text.encode("utf-8")
def setText(self, text):
if not len(text):
self.currPos = 0
- self.Text = ""
- elif isUTF8(text):
- self.Text = convertUTF8DVB(text, self.table)
+ self.Text = u""
else:
- self.Text = text
+ try:
+ self.Text = text.decode("utf-8")
+ except UnicodeDecodeError:
+ print "utf8 kaputt!"
+ self.Text = text
self.update()
def getText(self):
- return convertDVBUTF8(self.Text, self.table)
+ return self.Text.encode("utf-8")
def createWidget(self, parent):
return eLabel(parent, self.currPos)
self.update()
def handleAscii(self, code):
- newChar = chr(code)
+ newChar = unichr(code)
if self.overwrite==1:
self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
else:
self.lang = language.getLanguage()
if self.lang == 'de_DE':
- self.mapping.append (".,?'\"0-()@/:_") # 0
- self.mapping.append (" 1") # 1
- self.mapping.append ("aäbc2AÄBC") # 2
- self.mapping.append ("def3DEF") # 3
- self.mapping.append ("ghi4GHI") # 4
- self.mapping.append ("jkl5JKL") # 5
- self.mapping.append ("mnoö6MNOÖ") # 6
- self.mapping.append ("pqrsß7PQRSß") # 7
- self.mapping.append ("tuüv8TUÜV") # 8
- self.mapping.append ("wxyz9WXYZ") # 9
+ self.mapping.append (u".,?'\"0-()@/:_") # 0
+ self.mapping.append (u" 1") # 1
+ self.mapping.append (u"aäbc2AÄBC") # 2
+ self.mapping.append (u"def3DEF") # 3
+ self.mapping.append (u"ghi4GHI") # 4
+ self.mapping.append (u"jkl5JKL") # 5
+ self.mapping.append (u"mnoö6MNOÖ") # 6
+ self.mapping.append (u"pqrsß7PQRSß") # 7
+ self.mapping.append (u"tuüv8TUÜV") # 8
+ self.mapping.append (u"wxyz9WXYZ") # 9
elif self.lang == 'es_ES':
- self.mapping.append (".,?'\"0-()@/:_") # 0
- self.mapping.append (" 1") # 1
- self.mapping.append ("abcáà2ABCÁÀ") # 2
- self.mapping.append ("deéèf3DEFÉÈ") # 3
- self.mapping.append ("ghiíì4GHIÍÌ") # 4
- self.mapping.append ("jkl5JKL") # 5
- self.mapping.append ("mnñoóò6MNÑOÓÒ") # 6
- self.mapping.append ("pqrs7PQRS") # 7
- self.mapping.append ("tuvúù8TUVÚÙ") # 8
- self.mapping.append ("wxyz9WXYZ") # 9
+ self.mapping.append (u".,?'\"0-()@/:_") # 0
+ self.mapping.append (u" 1") # 1
+ self.mapping.append (u"abcáà2ABCÁÀ") # 2
+ self.mapping.append (u"deéèf3DEFÉÈ") # 3
+ self.mapping.append (u"ghiíì4GHIÍÌ") # 4
+ self.mapping.append (u"jkl5JKL") # 5
+ self.mapping.append (u"mnñoóò6MNÑOÓÒ") # 6
+ self.mapping.append (u"pqrs7PQRS") # 7
+ self.mapping.append (u"tuvúù8TUVÚÙ") # 8
+ self.mapping.append (u"wxyz9WXYZ") # 9
else:
- self.mapping.append (".,?'\"0-()@/:_") # 0
- self.mapping.append (" 1") # 1
- self.mapping.append ("abc2ABC") # 2
- self.mapping.append ("def3DEF") # 3
- self.mapping.append ("ghi4GHI") # 4
- self.mapping.append ("jkl5JKL") # 5
- self.mapping.append ("mno6MNO") # 6
- self.mapping.append ("pqrs7PQRS") # 7
- self.mapping.append ("tuv8TUV") # 8
- self.mapping.append ("wxyz9WXYZ") # 9
+ self.mapping.append (u".,?'\"0-()@/:_") # 0
+ self.mapping.append (u" 1") # 1
+ self.mapping.append (u"abc2ABC") # 2
+ self.mapping.append (u"def3DEF") # 3
+ self.mapping.append (u"ghi4GHI") # 4
+ self.mapping.append (u"jkl5JKL") # 5
+ self.mapping.append (u"mno6MNO") # 6
+ self.mapping.append (u"pqrs7PQRS") # 7
+ self.mapping.append (u"tuv8TUV") # 8
+ self.mapping.append (u"wxyz9WXYZ") # 9
self.nextFunction = nextFunction
self.Timer = eTimer()
self.pos = 0
def getKey(self, num):
- self.Timer.stop()
- self.Timer.start(1000)
+ self.Timer.start(1000, True)
if (self.lastKey != num):
self.lastKey = num
self.pos = 0
self.lastKey = -1
def nextChar(self):
- self.Timer.stop()
print "Timer done"
try:
self.nextKey()
if (self.nextFunction != None):
self.nextFunction()
- except:
- pass
+ except AttributeError:
+ print "Text Input object deleted with running nextChar timer?"