aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>2006-08-24 12:16:56 +0000
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>2006-08-24 12:16:56 +0000
commit65e19746f08f1287005861692322cdf868b06dc6 (patch)
tree67674e5b2a111f7674f80b3957e10358b914b5d5 /lib/python
parente09309bd7f69dbc98f471e28e01e2ad21ab7a757 (diff)
downloadenigma2-65e19746f08f1287005861692322cdf868b06dc6.tar.gz
enigma2-65e19746f08f1287005861692322cdf868b06dc6.zip
some NumericalInput and uncode/utf-8 fixes
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/Components/Input.py6
-rw-r--r--lib/python/Components/config.py39
-rw-r--r--lib/python/Screens/ChannelSelection.py7
-rw-r--r--lib/python/Tools/NumericalTextInput.py36
4 files changed, 50 insertions, 38 deletions
diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py
index e7713d6d..710ad0bc 100644
--- a/lib/python/Components/Input.py
+++ b/lib/python/Components/Input.py
@@ -6,19 +6,19 @@ from enigma import eLabel
from Tools.NumericalTextInput import NumericalTextInput
-class Input(VariableText, HTMLComponent, GUIComponent):
+class Input(VariableText, HTMLComponent, GUIComponent, NumericalTextInput):
TEXT = 0
PIN = 1
NUMBER = 2
def __init__(self, text="", maxSize = False, type = TEXT):
+ NumericalTextInput.__init__(self, self.right)
GUIComponent.__init__(self)
VariableText.__init__(self)
self.type = type
self.maxSize = maxSize
self.currPos = 0
self.overwrite = 0
- self.numericalTextInput = NumericalTextInput(self.right)
self.setText(text)
def update(self):
@@ -122,7 +122,7 @@ class Input(VariableText, HTMLComponent, GUIComponent):
def number(self, number):
if self.type == self.TEXT:
- newChar = self.numericalTextInput.getKey(number)
+ newChar = self.getKey(number)
elif self.type == self.PIN or self.type == self.NUMBER:
newChar = str(number)
self.Text = self.Text[0:self.currPos] + newChar + self.Text[self.currPos + 1:]
diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py
index c17e5aa1..7478653c 100644
--- a/lib/python/Components/config.py
+++ b/lib/python/Components/config.py
@@ -1,5 +1,5 @@
from time import *
-from Tools.NumericalTextInput import *
+from Tools.NumericalTextInput import NumericalTextInput
from Tools.Directories import *
class configFile:
@@ -335,30 +335,34 @@ class configNothing:
def __call__(self, selected): #needed by configlist
return ("text", "")
-class configText:
+class configText(NumericalTextInput):
# used as first parameter
# is the text of a fixed size or is the user able to extend the length of the text
extendableSize = 1
fixedSize = 2
def __init__(self, parent):
+ NumericalTextInput.__init__(self, self.nextEntry)
self.parent = parent
self.markedPos = 0
self.mode = self.parent.vals[0]
- self.textInput = NumericalTextInput(self.nextEntry)
+ try:
+ self.parent.value = self.parent.value.decode("utf-8")
+ except UnicodeDecodeError:
+ print "utf8 kaputt!"
def checkValues(self):
if (self.markedPos < 0):
self.markedPos = 0
if (self.markedPos >= len(self.parent.value)):
self.markedPos = len(self.parent.value) - 1
-
+
def cancel(self):
self.parent.reload()
def save(self):
self.parent.save()
-
+
def nextEntry(self):
self.parent.vals[1](self.parent.getConfigPath())
@@ -367,30 +371,25 @@ class configText:
#so we can handle it here in gui element
if key == config.key["delete"]:
self.parent.value = self.parent.value[0:self.markedPos] + self.parent.value[self.markedPos + 1:]
- if key == config.key["prevElement"]:
- self.textInput.nextKey()
+ elif key == config.key["prevElement"]:
+ self.nextKey()
self.markedPos -= 1
-
- if key == config.key["nextElement"]:
- self.textInput.nextKey()
+ elif key == config.key["nextElement"]:
+ self.nextKey()
self.markedPos += 1
if (self.mode == self.extendableSize):
if (self.markedPos >= len(self.parent.value)):
self.parent.value = self.parent.value.ljust(len(self.parent.value) + 1)
-
-
- if key >= config.key["0"] and key <= config.key["9"]:
+ elif key >= config.key["0"] and key <= config.key["9"]:
number = 9 - config.key["9"] + key
+ self.parent.value = self.parent.value[0:self.markedPos] + self.getKey(number) + self.parent.value[self.markedPos + 1:]
- self.parent.value = self.parent.value[0:self.markedPos] + str(self.textInput.getKey(number)) + self.parent.value[self.markedPos + 1:]
-
- self.checkValues()
-
- self.parent.change()
+ self.checkValues()
+ self.parent.change()
def __call__(self, selected): #needed by configlist
- return ("mtext"[1-selected:], str(self.parent.value), [self.markedPos])
-
+ return ("mtext"[1-selected:], self.parent.value.encode("utf-8"), [self.markedPos])
+
class configValue:
def __init__(self, obj):
self.obj = obj
diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py
index 01feaab1..a8d605ea 100644
--- a/lib/python/Screens/ChannelSelection.py
+++ b/lib/python/Screens/ChannelSelection.py
@@ -480,6 +480,7 @@ class ChannelSelectionBase(Screen):
self.servicelist = self["list"]
self.numericalTextInput = NumericalTextInput()
+ self.numericalTextInput.setUseableChars(u'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ')
self.servicePathTV = [ ]
self.servicePathRadio = [ ]
@@ -799,8 +800,10 @@ class ChannelSelectionBase(Screen):
self.enterPath(self.bouquet_root)
def keyNumberGlobal(self, number):
- char = self.numericalTextInput.getKey(number)
- self.servicelist.moveToChar(char)
+ unichar = self.numericalTextInput.getKey(number)
+ charstr = unichar.encode("utf-8")
+ if len(charstr) == 1:
+ self.servicelist.moveToChar(charstr[0])
def getRoot(self):
return self.servicelist.getRoot()
diff --git a/lib/python/Tools/NumericalTextInput.py b/lib/python/Tools/NumericalTextInput.py
index 1acd2548..87ac5486 100644
--- a/lib/python/Tools/NumericalTextInput.py
+++ b/lib/python/Tools/NumericalTextInput.py
@@ -3,9 +3,11 @@ from enigma import *
from Components.Language import language
class NumericalTextInput:
- def __init__(self, nextFunction = None):
+ def __init__(self, nextFunc=None):
self.mapping = []
self.lang = language.getLanguage()
+ self.useableChars=None
+ self.nextFunction=nextFunc
if self.lang == 'de_DE':
self.mapping.append (u".,?'\"0-()@/:_") # 0
@@ -40,22 +42,34 @@ class NumericalTextInput:
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.Timer.timeout.get().append(self.nextChar)
self.lastKey = -1
- self.pos = 0
+ self.pos = -1
+
+ def setUseableChars(self, useable):
+ self.useableChars = useable
def getKey(self, num):
+ cnt=0
self.Timer.start(1000, True)
if (self.lastKey != num):
self.lastKey = num
- self.pos = 0
- else:
+ self.pos = -1
+ while(True):
self.pos += 1
if (len(self.mapping[num]) <= self.pos):
self.pos = 0
+ if self.useableChars:
+ pos = self.useableChars.find(self.mapping[num][self.pos])
+ if pos == -1:
+ cnt += 1
+ if cnt < len(self.mapping[num]):
+ continue
+ else:
+ return None
+ break
return self.mapping[num][self.pos]
def nextKey(self):
@@ -63,10 +77,6 @@ class NumericalTextInput:
self.lastKey = -1
def nextChar(self):
- print "Timer done"
- try:
- self.nextKey()
- if (self.nextFunction != None):
- self.nextFunction()
- except AttributeError:
- print "Text Input object deleted with running nextChar timer?"
+ self.nextKey()
+ if self.nextFunction:
+ self.nextFunction()