textinput works now except for the nextCharacter-thing
[vuplus_dvbapp] / lib / python / Tools / NumericalTextInput.py
1 from enigma import *
2
3 class NumericalTextInput:
4     mapping = []
5     mapping.append ("abcABC") # 0
6     mapping.append ("abcABC") # 1
7     mapping.append ("abcABC") # 2
8     mapping.append ("defDEF") # 3
9     mapping.append ("ghiGHI") # 4
10     mapping.append ("jklJKL") # 5
11     mapping.append ("mnoMNO") # 6
12     mapping.append ("pqrsPQRS") # 7
13     mapping.append ("tuvTUV") # 8
14     mapping.append ("wxyzWXYZ") # 9
15
16
17     
18                                 
19     def __init__(self, nextFunction):
20         self.nextFunction = nextFunction
21         self.Timer = eTimer()
22         self.Timer.timeout.get().append(self.nextChar)
23         self.lastKey = -1
24         self.pos = 0
25     
26     def getKey(self, num):
27         self.Timer.stop()
28         self.Timer.start(1000)
29         if (self.lastKey != num):
30             self.lastKey = num
31             self.pos = 0
32         else:
33             self.pos += 1
34             if (len(self.mapping[num]) <= self.pos):
35                 self.pos = 0
36         return self.mapping[num][self.pos]
37     
38     def nextKey(self):
39         self.Timer.stop()
40         self.lastKey = -1
41     
42     def nextChar(self):
43         self.Timer.stop()
44         print "Timer done"
45         self.nextKey()
46         self.nextFunction()
47