From: Stefan Pluecken Date: Sat, 25 Feb 2006 04:05:35 +0000 (+0000) Subject: add InputBox screen for textual input X-Git-Tag: 2.6.0~3986 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/714488394a5c552b175f69682ac2001f8f1b6345?ds=inline add InputBox screen for textual input --- diff --git a/data/skin.xml b/data/skin.xml index 88af192e..92dfa0bb 100644 --- a/data/skin.xml +++ b/data/skin.xml @@ -338,6 +338,10 @@ + + + + """ diff --git a/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py b/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py index 5991f594..856c2f3b 100644 --- a/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py +++ b/lib/python/Plugins/DemoPlugins/TestPlugin/plugin.py @@ -7,6 +7,7 @@ from Components.Input import Input from Components.GUIComponent import * from Components.Pixmap import Pixmap from Components.FileList import FileEntryComponent, FileList +from Screens.InputBox import InputBox from Plugins.Plugin import PluginDescriptor import os @@ -45,6 +46,11 @@ class Test(Screen): "0": self.keyNumberGlobal }, -1) + self.onShown.append(self.openTest) + + def openTest(self): + self.session.open(InputBox) + def keyLeft(self): self["text"].left() @@ -63,7 +69,12 @@ class Test(Screen): self["text"].number(number) def main(session): - session.open(Test) + session.openWithCallback(test, InputBox, title="Hallo", text="1234", maxSize=True, type=Input.NUMBER) + +def test(returnValue): + print "You entered", returnValue def Plugins(): return PluginDescriptor(name="Test", description="plugin to test some capabilities", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main) + + \ No newline at end of file diff --git a/lib/python/Screens/InputBox.py b/lib/python/Screens/InputBox.py new file mode 100644 index 00000000..6771a517 --- /dev/null +++ b/lib/python/Screens/InputBox.py @@ -0,0 +1,50 @@ +from enigma import * +from Screens.Screen import Screen +from Screens.MessageBox import MessageBox +from Components.ActionMap import NumberActionMap +from Components.Label import Label +from Components.Input import Input +from Components.GUIComponent import * + +import os + +class InputBox(Screen): + def __init__(self, session, title = "", **kwargs): + Screen.__init__(self, session) + + self["text"] = Label(title) + self["input"] = Input(**kwargs) + + self["actions"] = NumberActionMap(["WizardActions", "InputActions"], + { + "ok": self.go, + "back": self.close, + "left": self.keyLeft, + "right": self.keyRight, + "1": self.keyNumberGlobal, + "2": self.keyNumberGlobal, + "3": self.keyNumberGlobal, + "4": self.keyNumberGlobal, + "5": self.keyNumberGlobal, + "6": self.keyNumberGlobal, + "7": self.keyNumberGlobal, + "8": self.keyNumberGlobal, + "9": self.keyNumberGlobal, + "0": self.keyNumberGlobal + }, -1) + + def keyLeft(self): + self["input"].left() + + def keyRight(self): + self["input"].right() + + def keyNumberGlobal(self, number): + print "pressed", number + self["input"].number(number) + + def go(self): + self.close(self["input"].getText()) + + def cancel(self): + self.close(None) \ No newline at end of file diff --git a/lib/python/Screens/Makefile.am b/lib/python/Screens/Makefile.am index 3365e97f..63eecb18 100644 --- a/lib/python/Screens/Makefile.am +++ b/lib/python/Screens/Makefile.am @@ -9,5 +9,5 @@ install_PYTHON = \ AudioSelection.py InfoBarGenerics.py HelpMenu.py Wizard.py __init__.py \ Dish.py SubserviceSelection.py LanguageSelection.py StartWizard.py \ TutorialWizard.py PluginBrowser.py MinuteInput.py Scart.py PVRState.py \ - Console.py + Console.py InputBox.py diff --git a/lib/python/Screens/__init__.py b/lib/python/Screens/__init__.py index 06378dc3..d5323bb8 100644 --- a/lib/python/Screens/__init__.py +++ b/lib/python/Screens/__init__.py @@ -5,4 +5,4 @@ __all__ = ["ChannelSelection", "ClockDisplay", "ConfigMenu", "Satconfig", "Scanconfig", "Ci.py", "Volume.py", "Mute.py", "EpgSelection", "EventView", "Standby", "ServiceInfo", "AudioSelection", "SubserviceSelection", "InfoBarGenerics", "HelpMenu", "Wizard", - "PVRState", "Console" ] + "PVRState", "Console", "InputBox" ]