add a small text input component
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 19 Jan 2006 02:18:21 +0000 (02:18 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 19 Jan 2006 02:18:21 +0000 (02:18 +0000)
configure.ac
data/keymap.xml
lib/python/Components/Input.py [new file with mode: 0644]
lib/python/Components/Makefile.am
lib/python/Components/PluginComponent.py
lib/python/Plugins/Makefile.am
lib/python/Plugins/test/Makefile.am [new file with mode: 0644]
lib/python/Plugins/test/__init__.py [new file with mode: 0644]
lib/python/Plugins/test/plugin.py [new file with mode: 0644]
lib/python/Screens/TimerEdit.py

index 6d2da01..0fe3c48 100644 (file)
@@ -59,6 +59,7 @@ lib/python/Components/Makefile
 lib/python/Screens/Makefile
 lib/python/Plugins/Makefile
 lib/python/Plugins/update/Makefile
+lib/python/Plugins/test/Makefile
 lib/python/Plugins/tuxboxplugins/Makefile
 lib/python/Plugins/web/Makefile
 lib/python/Tools/Makefile
index 39ded6a..2034aa1 100644 (file)
                <key id="KEY_9" mapto="9" flags="m" />
                <key id="KEY_0" mapto="0" flags="m" />
        </map>
+       
+       <map context="InputActions">
+               <key id="KEY_LEFT" mapto="left" flags="mr" />
+               <key id="KEY_RIGHT" mapto="right" flags="mr" />
+               <key id="KEY_1" mapto="1" flags="m" />
+               <key id="KEY_2" mapto="2" flags="m" />
+               <key id="KEY_3" mapto="3" flags="m" />
+               <key id="KEY_4" mapto="4" flags="m" />
+               <key id="KEY_5" mapto="5" flags="m" />
+               <key id="KEY_6" mapto="6" flags="m" />
+               <key id="KEY_7" mapto="7" flags="m" />
+               <key id="KEY_8" mapto="8" flags="m" />
+               <key id="KEY_9" mapto="9" flags="m" />
+               <key id="KEY_0" mapto="0" flags="m" />
+       </map>
 
        <map context="InfobarEPGActions">
                <key id="KEY_INFO" mapto="showEPGList" flags="m" />
diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py
new file mode 100644 (file)
index 0000000..d3b0661
--- /dev/null
@@ -0,0 +1,46 @@
+from HTMLComponent import *
+from GUIComponent import *
+from VariableText import *
+
+from enigma import eLabel
+
+from Tools.NumericalTextInput import NumericalTextInput
+
+class Input(HTMLComponent, GUIComponent, VariableText):
+       def __init__(self, text=""):
+               GUIComponent.__init__(self)
+               VariableText.__init__(self)
+               self.numericalTextInput = NumericalTextInput(self.right)
+               self.currPos = 0
+               self.text = text
+               self.update()
+
+       def update(self):
+               self.setText(self.text[0:self.currPos] + "_" + self.text[self.currPos] + "_" + self.text[self.currPos + 1:])
+       
+       def createWidget(self, parent):
+               return eLabel(parent)
+       
+       def getSize(self):
+               s = self.instance.calculateSize()
+               return (s.width(), s.height())
+       
+       def right(self):
+               self.currPos += 1
+               if self.currPos == len(self.text):
+                       self.text = self.text + " "
+               self.update()
+               
+       def left(self):
+               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:]
+               self.update()
+
+       def show(self):
+               self.instance.show()
+
+       def hide(self):
+               self.instance.hide()
\ No newline at end of file
index 089d7ce..945946d 100644 (file)
@@ -12,5 +12,5 @@ install_PYTHON = \
        EpgList.py ScrollLabel.py Timezones.py Language.py HelpMenuList.py \
        BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py LanguageList.py \
        PluginList.py PluginComponent.py RecordingConfig.py About.py UsageConfig.py \
-       FIFOList.py ServiceEventTracker.py
+       FIFOList.py ServiceEventTracker.py Input.py
 
index adfc98a..26eadd1 100644 (file)
@@ -20,38 +20,38 @@ class PluginComponent:
 
                for x in dir:
                        path = resolveFilename(SCOPE_PLUGINS, x) + "/"
-                       try:
-                               if os.path.exists(path):
-                                       if fileExists(path + "plugin.py"):
-                                               pluginmodule = self.prefix + x + ".plugin"
-                                               print "trying to import " + pluginmodule
-                                               exec "import " + pluginmodule
-                                               plugin = eval(pluginmodule)
-                                               plugins = plugin.getPlugins()
-                                               try: picturepaths = plugin.getPicturePaths()
-                                               except:
-                                                       picturepaths = []
-                                                       for p in plugins:
-                                                               picturepaths.append("")
-                                               try:
-                                                       for menuEntry in plugin.getMenuRegistrationList():
-                                                               self.menuEntries.append([menuEntry, pluginmodule])
-                                               except:
-                                                       pass
-       
-                                               for y in range(len(plugins)):
-                                                       if len(plugins[y]) < 5:
-                                                               list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][2], plugins[y][3], None, plugins[y][1]))
-                                                       else:
-                                                               list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][2], plugins[y][3], plugins[y][4], plugins[y][1]))
-                                               if runAutostartPlugins:
-                                                       try: plugin.autostart()
-                                                       except: pass
-                                               if runAutoendPlugins:
-                                                       try: plugin.autoend()
-                                                       except: pass
-                       except:
-                               print "Directory", path, "contains a faulty plugin"
+#                      try:
+                       if os.path.exists(path):
+                               if fileExists(path + "plugin.py"):
+                                       pluginmodule = self.prefix + x + ".plugin"
+                                       print "trying to import " + pluginmodule
+                                       exec "import " + pluginmodule
+                                       plugin = eval(pluginmodule)
+                                       plugins = plugin.getPlugins()
+                                       try: picturepaths = plugin.getPicturePaths()
+                                       except:
+                                               picturepaths = []
+                                               for p in plugins:
+                                                       picturepaths.append("")
+                                       try:
+                                               for menuEntry in plugin.getMenuRegistrationList():
+                                                       self.menuEntries.append([menuEntry, pluginmodule])
+                                       except:
+                                               pass
+
+                                       for y in range(len(plugins)):
+                                               if len(plugins[y]) < 5:
+                                                       list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][2], plugins[y][3], None, plugins[y][1]))
+                                               else:
+                                                       list.append((path + picturepaths[y], plugins[y][0] , x, plugins[y][2], plugins[y][3], plugins[y][4], plugins[y][1]))
+                                       if runAutostartPlugins:
+                                               try: plugin.autostart()
+                                               except: pass
+                                       if runAutoendPlugins:
+                                               try: plugin.autoend()
+                                               except: pass
+#                      except:
+#                              print "Directory", path, "contains a faulty plugin"
                self.menuUpdate()
                return list
        
index 01f21d4..93ee65a 100644 (file)
@@ -1,6 +1,6 @@
 installdir = $(LIBDIR)/enigma2/python/Plugins
 
-SUBDIRS = update tuxboxplugins web
+SUBDIRS = update tuxboxplugins web test
 
 install_PYTHON =       \
        __init__.py
diff --git a/lib/python/Plugins/test/Makefile.am b/lib/python/Plugins/test/Makefile.am
new file mode 100644 (file)
index 0000000..c841c49
--- /dev/null
@@ -0,0 +1,6 @@
+installdir = $(LIBDIR)/enigma2/python/Plugins/test
+
+install_PYTHON =       \
+       __init__.py \
+       plugin.py
diff --git a/lib/python/Plugins/test/__init__.py b/lib/python/Plugins/test/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lib/python/Plugins/test/plugin.py b/lib/python/Plugins/test/plugin.py
new file mode 100644 (file)
index 0000000..c08a986
--- /dev/null
@@ -0,0 +1,55 @@
+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 Test(Screen):
+       skin = """
+               <screen position="100,100" size="550,400" title="Test" >
+                       <widget name="text" position="0,0" size="550,400" font="Regular;20" />
+               </screen>"""
+               
+       def __init__(self, session, args = None):
+               self.skin = Test.skin
+               Screen.__init__(self, session)
+
+               self["text"] = Input("Please press OK!")
+                               
+               self["actions"] = NumberActionMap(["WizardActions", "InputActions"], 
+               {
+                       "ok": self.close,
+                       "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["text"].left()
+       
+       def keyRight(self):
+               self["text"].right()
+       
+       def keyNumberGlobal(self, number):
+               print "pressed", number
+               self["text"].number(number)
+
+def getPicturePaths():
+       return [ "" ]
+
+def getPlugins():
+       return [("Test", "plugin to test some capabilities", "screen", "Test")]
index ff2a017..560ec94 100644 (file)
@@ -4,7 +4,6 @@ from Components.ActionMap import ActionMap
 from Components.TimeInput import TimeInput
 from Components.Label import Label
 from Components.Button import Button
-from Components.TextInput import TextInput
 from TimerEntry import TimerEntry
 from RecordTimer import RecordTimerEntry, parseEvent
 from time import *