from HTMLComponent import *
from GUIComponent import *
-from config import KEY_LEFT, KEY_RIGHT, KEY_0, KEY_DELETE, KEY_OK, KEY_TIMEOUT
+from config import KEY_LEFT, KEY_RIGHT, KEY_0, KEY_DELETE, KEY_OK, KEY_TIMEOUT, ConfigElement
from Components.ActionMap import NumberActionMap
from enigma import eListbox, eListboxPythonConfigContent, eTimer
GUIComponent.__init__(self)
self.l = eListboxPythonConfigContent()
self.l.setSeperation(100)
+ self.timer = eTimer()
+ self.timer.timeout.get().append(self.timeout)
self.list = list
self.onSelectionChanged = [ ]
self.current = None
self.help_window = None
self.setHelpWindowSession(session)
-
+
+ def execEnd(self):
self.timer = eTimer()
self.timer.timeout.get().append(self.timeout)
-
+
def setHelpWindowSession(self, session):
assert self.help_window is None, "you can't move a help window to another session"
self.session = session
def handleKey(self, key):
selection = self.getCurrent()
- if selection[1].enabled:
+ if selection and selection[1].enabled:
selection[1].handleKey(key)
self.invalidateCurrent()
if self.help_window:
self.help_window.update(selection[1])
- if key not in [KEY_TIMEOUT, KEY_LEFT, KEY_RIGHT, KEY_DELETE, KEY_OK]:
- self.timer.start(1000, 1)
+ if key not in [KEY_TIMEOUT, KEY_LEFT, KEY_RIGHT, KEY_DELETE, KEY_OK]:
+ self.timer.start(1000, 1)
def getCurrent(self):
return self.l.getCurrentSelection()
n = self.getCurrent()
if self.help_window:
- print "close old help window!"
self.session.deleteDialog(self.help_window)
nh = n and n[1].helpWindow()
- print "n, nh:", n, nh
if nh is not None and self.session is not None:
- print "show new help window"
self.help_window = self.session.instantiateDialog(*nh)
self.help_window.show()
- print "config selection changed, from ", self.current, " to ", n
self.current = n
for x in self.onSelectionChanged:
x()
def preWidgetRemove(self, instance):
instance.selectionChanged.get().remove(self.selectionChanged)
- def setList(self, list):
- self.__list = list
+ def setList(self, l):
+ self.timer.stop()
+ self.__list = l
self.l.setList(self.__list)
+ if l is not None:
+ for x in l:
+ assert isinstance(x[1], ConfigElement), "entry in ConfigList " + str(x[1]) + " must be a ConfigElement"
+
def getList(self):
return self.__list
"8": self.keyNumberGlobal,
"9": self.keyNumberGlobal,
"0": self.keyNumberGlobal
- }, -1)
-
+ }, -1) # to prevent left/right overriding the listbox
+
self["config"] = ConfigList(list, session = session)
def keyOK(self):