fix non working code
[enigma2.git] / lib / python / Tools / NumericalTextInput.py
1 # -*- coding: latin-1 -*-
2 from enigma import *
3 from Components.Language import language
4
5 class NumericalTextInput:
6         def __init__(self, nextFunction = None):
7                 self.mapping = []
8                 self.lang = language.getLanguage()
9                 
10                 if self.lang == 'de_DE':
11                         self.mapping.append (".,?'\"0-()@/:_") # 0
12                         self.mapping.append (" 1") # 1
13                         self.mapping.append ("aäbc2AABC") # 2
14                         self.mapping.append ("def3DEF") # 3
15                         self.mapping.append ("ghi4GHI") # 4
16                         self.mapping.append ("jkl5JKL") # 5
17                         self.mapping.append ("mnoö6MNOÖ") # 6
18                         self.mapping.append ("pqrsß7PQRSß") # 7
19                         self.mapping.append ("tuüv8TUÜV") # 8
20                         self.mapping.append ("wxyz9WXYZ") # 9
21                 elif self.lang == 'es_ES':
22                         self.mapping.append (".,?'\"0-()@/:_") # 0
23                         self.mapping.append (" 1") # 1
24                         self.mapping.append ("abcáà2ABCÁÀ") # 2
25                         self.mapping.append ("deéèf3DEFÉÈ") # 3
26                         self.mapping.append ("ghiíì4GHIÍÌ") # 4
27                         self.mapping.append ("jkl5JKL") # 5
28                         self.mapping.append ("mnñoóò6MNÑOÓÒ") # 6
29                         self.mapping.append ("pqrs7PQRS") # 7
30                         self.mapping.append ("tuvúù8TUVÚÙ") # 8
31                         self.mapping.append ("wxyz9WXYZ") # 9
32                 else:
33                         self.mapping.append (".,?'\"0-()@/:_") # 0
34                         self.mapping.append (" 1") # 1
35                         self.mapping.append ("abc2ABC") # 2
36                         self.mapping.append ("def3DEF") # 3
37                         self.mapping.append ("ghi4GHI") # 4
38                         self.mapping.append ("jkl5JKL") # 5
39                         self.mapping.append ("mno6MNO") # 6
40                         self.mapping.append ("pqrs7PQRS") # 7
41                         self.mapping.append ("tuv8TUV") # 8
42                         self.mapping.append ("wxyz9WXYZ") # 9
43                 
44                 self.nextFunction = nextFunction
45                 self.Timer = eTimer()
46                 self.Timer.timeout.get().append(self.nextChar)
47                 self.lastKey = -1
48                 self.pos = 0
49
50         def getKey(self, num):
51                 self.Timer.stop()
52                 self.Timer.start(1000)
53                 if (self.lastKey != num):
54                         self.lastKey = num
55                         self.pos = 0
56                 else:
57                         self.pos += 1
58                         if (len(self.mapping[num]) <= self.pos):
59                                 self.pos = 0
60                 return self.mapping[num][self.pos]
61
62         def nextKey(self):
63                 self.Timer.stop()
64                 self.lastKey = -1
65
66         def nextChar(self):
67                 self.Timer.stop()
68                 print "Timer done"
69                 try:
70                         self.nextKey()
71                         if (self.nextFunction != None):
72                                 self.nextFunction()
73                 except:
74                         pass