aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-01-19 03:59:43 +0000
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-01-19 03:59:43 +0000
commit73c8ccf2a900e59f8450ddad57b80a215bb658b4 (patch)
tree9f9b663559a3d2629abe37609d918b0761ba0eda /lib/python
parentb4448ddb042e5f5015125597633e368f17acbcec (diff)
downloadenigma2-73c8ccf2a900e59f8450ddad57b80a215bb658b4.tar.gz
enigma2-73c8ccf2a900e59f8450ddad57b80a215bb658b4.zip
use Components.Input in seek window
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/Components/Input.py45
-rw-r--r--lib/python/Plugins/test/plugin.py2
-rw-r--r--lib/python/Screens/MinuteInput.py27
3 files changed, 57 insertions, 17 deletions
diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py
index 7ffc5c77..a0252e46 100644
--- a/lib/python/Components/Input.py
+++ b/lib/python/Components/Input.py
@@ -7,19 +7,30 @@ from enigma import eLabel
from Tools.NumericalTextInput import NumericalTextInput
class Input(HTMLComponent, GUIComponent, VariableText):
- def __init__(self, text=""):
+ 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)
- self.setText(self.text)
+ 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)
@@ -31,15 +42,41 @@ class Input(HTMLComponent, GUIComponent, VariableText):
def right(self):
self.currPos += 1
if self.currPos == len(self.text):
- self.text = 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):
- self.text = self.text[0:self.currPos] + self.numericalTextInput.getKey(number) + self.text[self.currPos + 1:]
+ 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()
def show(self):
diff --git a/lib/python/Plugins/test/plugin.py b/lib/python/Plugins/test/plugin.py
index d85a80c9..90c45e6e 100644
--- a/lib/python/Plugins/test/plugin.py
+++ b/lib/python/Plugins/test/plugin.py
@@ -18,7 +18,7 @@ class Test(Screen):
self.skin = Test.skin
Screen.__init__(self, session)
- self["text"] = Input("Please press OK!")
+ self["text"] = Input("1234", maxSize=True, type=Input.NUMBER)
self["actions"] = NumberActionMap(["WizardActions", "InputActions"],
{
diff --git a/lib/python/Screens/MinuteInput.py b/lib/python/Screens/MinuteInput.py
index 68909b61..d804570f 100644
--- a/lib/python/Screens/MinuteInput.py
+++ b/lib/python/Screens/MinuteInput.py
@@ -4,16 +4,16 @@ from Components.Label import Label
from Components.Button import Button
from Components.Pixmap import Pixmap
from Components.MenuList import MenuList
+from Components.Input import Input
from enigma import eSize, ePoint
class MinuteInput(Screen):
def __init__(self, session, basemins = 5):
Screen.__init__(self, session)
- self["minutes"] = Label()
- self.updateValue(basemins)
+ self["minutes"] = Input(str(basemins), type=Input.NUMBER)
- self["actions"] = NumberActionMap([ "NumberZapActions", "MinuteInputActions" ],
+ self["actions"] = NumberActionMap([ "InputActions" , "MinuteInputActions" ],
{
"1": self.keyNumberGlobal,
"2": self.keyNumberGlobal,
@@ -25,29 +25,32 @@ class MinuteInput(Screen):
"8": self.keyNumberGlobal,
"9": self.keyNumberGlobal,
"0": self.keyNumberGlobal,
+ "left": self.left,
+ "right": self.right,
"up": self.up,
"down": self.down,
"ok": self.ok,
"cancel": self.cancel
})
- def updateValue(self, minutes):
- self.minutes = minutes
- self["minutes"].setText(str(self.minutes) + _(" mins"))
-
def keyNumberGlobal(self, number):
- #self.updateValue(self.minutes * 10 + number)
+ self["minutes"].number(number)
pass
+ def left(self):
+ self["minutes"].left()
+
+ def right(self):
+ self["minutes"].right()
+
def up(self):
- self.updateValue(self.minutes + 1)
+ self["minutes"].up()
def down(self):
- if self.minutes > 0:
- self.updateValue(self.minutes - 1)
+ self["minutes"].down()
def ok(self):
- self.close(self.minutes)
+ self.close(int(self["minutes"].getText()))
def cancel(self):
self.close(0) \ No newline at end of file