blob: f1a17d90b8f042453d18418a4c9ff9af4b648506 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
from HTMLComponent import *
from GUIComponent import *
from VariableText import *
from enigma import eLabel
from Tools.NumericalTextInput import NumericalTextInput
class Input(HTMLComponent, GUIComponent, VariableText):
TEXT = 0
PIN = 1
NUMBER = 2
def __init__(self, text="", maxSize = False, type = TEXT):
GUIComponent.__init__(self)
VariableText.__init__(self)
self.numericalTextInput = NumericalTextInput(self.right)
self.type = type
self.maxSize = maxSize
self.currPos = 0
self.text = text
self.update()
def update(self):
self.setMarkedPos(self.currPos)
text = self.text
if self.type == self.PIN:
text = "*" * len(self.text)
self.setText(text)
#self.setText(self.text[0:self.currPos] + "_" + self.text[self.currPos] + "_" + self.text[self.currPos + 1:])
def getText(self):
return self.text
def createWidget(self, parent):
return eLabel(parent, self.currPos)
def getSize(self):
s = self.instance.calculateSize()
return (s.width(), s.height())
def right(self):
self.currPos += 1
if self.currPos == len(self.text):
if self.maxSize:
self.currPos -= 1
else:
self.text = self.text + " "
self.update()
def left(self):
self.currPos -= 1
self.update()
def up(self):
if self.text[self.currPos] == "9":
newNumber = "0"
else:
newNumber = str(int(self.text[self.currPos]) + 1)
self.text = self.text[0:self.currPos] + newNumber + self.text[self.currPos + 1:]
self.update()
def down(self):
if self.text[self.currPos] == "0":
newNumber = "9"
else:
newNumber = str(int(self.text[self.currPos]) - 1)
self.text = self.text[0:self.currPos] + newNumber + self.text[self.currPos + 1:]
self.update()
def number(self, number):
if self.type == self.TEXT:
newChar = self.numericalTextInput.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:]
if self.type == self.PIN or self.type == self.NUMBER:
self.right()
self.update()
|