add InputBox screen for textual input
[enigma2.git] / lib / python / Plugins / DemoPlugins / TestPlugin / plugin.py
1 from enigma import *
2 from Screens.Screen import Screen
3 from Screens.MessageBox import MessageBox
4 from Components.ActionMap import NumberActionMap
5 from Components.Label import Label
6 from Components.Input import Input
7 from Components.GUIComponent import *
8 from Components.Pixmap import Pixmap
9 from Components.FileList import FileEntryComponent, FileList
10 from Screens.InputBox import InputBox
11 from Plugins.Plugin import PluginDescriptor
12
13 import os
14
15 class Test(Screen):
16         skin = """
17                 <screen position="100,100" size="550,400" title="Test" >
18                         <!--widget name="text" position="0,0" size="550,25" font="Regular;20" /-->
19                         <widget name="list" position="10,0" size="190,250" scrollbarMode="showOnDemand" />
20                         <widget name="pixmap" position="200,0" size="190,250" />
21                 </screen>"""
22         def __init__(self, session, args = None):
23                 self.skin = Test.skin
24                 Screen.__init__(self, session)
25
26                 self["list"] = FileList("/", matchingPattern = "^.*\.(png|avi|mp3|mpeg|ts)")
27                 self["pixmap"] = Pixmap()
28                 
29                 #self["text"] = Input("1234", maxSize=True, type=Input.NUMBER)
30                                 
31                 self["actions"] = NumberActionMap(["WizardActions", "InputActions"],
32                 {
33                         "ok": self.ok,
34                         "back": self.close,
35 #                       "left": self.keyLeft,
36 #                       "right": self.keyRight,
37                         "1": self.keyNumberGlobal,
38                         "2": self.keyNumberGlobal,
39                         "3": self.keyNumberGlobal,
40                         "4": self.keyNumberGlobal,
41                         "5": self.keyNumberGlobal,
42                         "6": self.keyNumberGlobal,
43                         "7": self.keyNumberGlobal,
44                         "8": self.keyNumberGlobal,
45                         "9": self.keyNumberGlobal,
46                         "0": self.keyNumberGlobal
47                 }, -1)
48                 
49                 self.onShown.append(self.openTest)
50
51         def openTest(self):
52                 self.session.open(InputBox)
53                 
54         def keyLeft(self):
55                 self["text"].left()
56         
57         def keyRight(self):
58                 self["text"].right()
59         
60         def ok(self):
61                 selection = self["list"].getSelection()
62                 if selection[1] == True: # isDir
63                         self["list"].changeDir(selection[0])
64                 else:
65                         self["pixmap"].instance.setPixmapFromFile(selection[0])
66         
67         def keyNumberGlobal(self, number):
68                 print "pressed", number
69                 self["text"].number(number)
70
71 def main(session):
72         session.openWithCallback(test, InputBox, title="Hallo", text="1234", maxSize=True, type=Input.NUMBER)
73         
74 def test(returnValue):
75         print "You entered", returnValue
76
77 def Plugins():
78         return PluginDescriptor(name="Test", description="plugin to test some capabilities", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)
79
80