new plugin interface
[enigma2.git] / lib / python / Plugins / test / 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 Plugins.Plugin import PluginDescriptor
9
10 import os
11
12 class Test(Screen):
13         skin = """
14                 <screen position="100,100" size="550,400" title="Test" >
15                         <widget name="text" position="0,0" size="550,25" font="Regular;20" />
16                 </screen>"""
17                 
18         def __init__(self, session, args = None):
19                 self.skin = Test.skin
20                 Screen.__init__(self, session)
21
22                 self["text"] = Input("1234", maxSize=True, type=Input.NUMBER)
23                                 
24                 self["actions"] = NumberActionMap(["WizardActions", "InputActions"], 
25                 {
26                         "ok": self.close,
27                         "back": self.close,
28                         "left": self.keyLeft,
29                         "right": self.keyRight,
30                         "1": self.keyNumberGlobal,
31                         "2": self.keyNumberGlobal,
32                         "3": self.keyNumberGlobal,
33                         "4": self.keyNumberGlobal,
34                         "5": self.keyNumberGlobal,
35                         "6": self.keyNumberGlobal,
36                         "7": self.keyNumberGlobal,
37                         "8": self.keyNumberGlobal,
38                         "9": self.keyNumberGlobal,
39                         "0": self.keyNumberGlobal
40                 }, -1)
41                 
42         def keyLeft(self):
43                 self["text"].left()
44         
45         def keyRight(self):
46                 self["text"].right()
47         
48         def keyNumberGlobal(self, number):
49                 print "pressed", number
50                 self["text"].number(number)
51
52 def main(session):
53         session.open(Test)
54
55 def Plugins():
56         return PluginDescriptor(name="Test", description="plugin to test some capabilities", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)