6771a517d70aa9471f0db440b8a46cd295e5c0ac
[enigma2.git] / lib / python / Screens / InputBox.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
9 import os
10
11 class InputBox(Screen):
12         def __init__(self, session, title = "", **kwargs):
13                 Screen.__init__(self, session)
14
15                 self["text"] = Label(title)
16                 self["input"] = Input(**kwargs)
17                                 
18                 self["actions"] = NumberActionMap(["WizardActions", "InputActions"], 
19                 {
20                         "ok": self.go,
21                         "back": self.close,
22                         "left": self.keyLeft,
23                         "right": self.keyRight,
24                         "1": self.keyNumberGlobal,
25                         "2": self.keyNumberGlobal,
26                         "3": self.keyNumberGlobal,
27                         "4": self.keyNumberGlobal,
28                         "5": self.keyNumberGlobal,
29                         "6": self.keyNumberGlobal,
30                         "7": self.keyNumberGlobal,
31                         "8": self.keyNumberGlobal,
32                         "9": self.keyNumberGlobal,
33                         "0": self.keyNumberGlobal
34                 }, -1)
35                 
36         def keyLeft(self):
37                 self["input"].left()
38         
39         def keyRight(self):
40                 self["input"].right()
41         
42         def keyNumberGlobal(self, number):
43                 print "pressed", number
44                 self["input"].number(number)
45                 
46         def go(self):
47                 self.close(self["input"].getText())
48                 
49         def cancel(self):
50                 self.close(None)