aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Tools/NumericalTextInput.py
blob: 260f80b4217d38e2024245b4a1ab759c42ea1764 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from enigma import *

class NumericalTextInput:
    mapping = []
    mapping.append ("abcABC") # 0
    mapping.append ("abcABC") # 1
    mapping.append ("abcABC") # 2
    mapping.append ("defDEF") # 3
    mapping.append ("ghiGHI") # 4
    mapping.append ("jklJKL") # 5
    mapping.append ("mnoMNO") # 6
    mapping.append ("pqrsPQRS") # 7
    mapping.append ("tuvTUV") # 8
    mapping.append ("wxyzWXYZ") # 9


    
                                
    def __init__(self, nextFunction):
        self.nextFunction = nextFunction
        self.Timer = eTimer()
        self.Timer.timeout.get().append(self.nextChar)
        self.lastKey = -1
        self.pos = 0
    
    def getKey(self, num):
        self.Timer.stop()
        self.Timer.start(1000)
        if (self.lastKey != num):
            self.lastKey = num
            self.pos = 0
        else:
            self.pos += 1
            if (len(self.mapping[num]) <= self.pos):
                self.pos = 0
        return self.mapping[num][self.pos]
    
    def nextKey(self):
        self.Timer.stop()
        self.lastKey = -1
    
    def nextChar(self):
        self.Timer.stop()
        print "Timer done"
        self.nextKey()
        self.nextFunction()