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 *
11 class InputBox(Screen):
12 def __init__(self, session, title = "", **kwargs):
13 Screen.__init__(self, session)
15 self["text"] = Label(title)
16 self["input"] = Input(**kwargs)
18 self["actions"] = NumberActionMap(["WizardActions", "InputBoxActions", "InputAsciiActions", "KeyboardInputActions"],
20 "gotAsciiCode": self.gotAsciiCode,
24 "right": self.keyRight,
25 "delete": self.keyDelete,
26 "moveLeft": self.keyLeft,
27 "moveRight": self.keyRight,
28 "moveHome": self.keyHome,
29 "moveEnd": self.keyEnd,
30 "deleteForward": self.keyDelete,
31 "deleteBackward": self.keyBackspace,
33 "toggleOverwrite": self.keyInsert,
35 "1": self.keyNumberGlobal,
36 "2": self.keyNumberGlobal,
37 "3": self.keyNumberGlobal,
38 "4": self.keyNumberGlobal,
39 "5": self.keyNumberGlobal,
40 "6": self.keyNumberGlobal,
41 "7": self.keyNumberGlobal,
42 "8": self.keyNumberGlobal,
43 "9": self.keyNumberGlobal,
44 "0": self.keyNumberGlobal
46 rcinput = eRCInput.getInstance()
47 rcinput.setKeyboardMode(rcinput.kmAscii)
49 def gotAsciiCode(self):
50 self["input"].handleAscii(getPrevAsciiCode())
58 def keyNumberGlobal(self, number):
59 self["input"].number(number)
62 self["input"].delete()
65 rcinput = eRCInput.getInstance()
66 rcinput.setKeyboardMode(rcinput.kmNone)
67 self.close(self["input"].getText())
70 rcinput = eRCInput.getInstance()
71 rcinput.setKeyboardMode(rcinput.kmNone)
80 def keyBackspace(self):
81 self["input"].deleteBackward()
87 self["input"].toggleOverwrite()