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