add some characters to NumericalTextInput
[vuplus_dvbapp] / lib / python / Tools / NumericalTextInput.py
1 from enigma import *
2
3 class NumericalTextInput:
4     mapping = []
5     mapping.append (".,?'\"0") # 0
6     mapping.append (" 1") # 1
7     mapping.append ("abc2ABC") # 2
8     mapping.append ("def3DEF") # 3
9     mapping.append ("ghi4GHI") # 4
10     mapping.append ("jkl5JKL") # 5
11     mapping.append ("mno6MNO") # 6
12     mapping.append ("pqrs7PQRS") # 7
13     mapping.append ("tuv8TUV") # 8
14     mapping.append ("wxyz9WXYZ") # 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