1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
4 from enigma import eListboxPythonStringContent, eListbox
6 class MenuList(HTMLComponent, GUIComponent):
7 def __init__(self, list, enableWrapAround=False, content=eListboxPythonStringContent):
8 GUIComponent.__init__(self)
11 self.l.setList(self.list)
12 self.onSelectionChanged = [ ]
13 self.enableWrapAround = enableWrapAround
16 return self.l.getCurrentSelection()
20 def postWidgetCreate(self, instance):
21 instance.setContent(self.l)
22 instance.selectionChanged.get().append(self.selectionChanged)
23 if self.enableWrapAround:
24 self.instance.setWrapAround(True)
26 def preWidgetRemove(self, instance):
27 instance.setContent(None)
28 instance.selectionChanged.get().remove(self.selectionChanged)
30 def selectionChanged(self):
31 for f in self.onSelectionChanged:
34 def getSelectionIndex(self):
35 return self.l.getCurrentSelectionIndex()
37 def getSelectedIndex(self):
38 return self.l.getCurrentSelectionIndex()
40 def setList(self, list):
42 self.l.setList(self.list)
44 def moveToIndex(self, idx):
45 if self.instance is not None:
46 self.instance.moveSelectionTo(idx)
49 if self.instance is not None:
50 self.instance.moveSelection(self.instance.pageUp)
53 if self.instance is not None:
54 self.instance.moveSelection(self.instance.pageDown)
57 if self.instance is not None:
58 self.instance.moveSelection(self.instance.moveUp)
61 if self.instance is not None:
62 self.instance.moveSelection(self.instance.moveDown)
64 def selectionEnabled(self, enabled):
65 if self.instance is not None:
66 self.instance.setSelectionEnable(enabled)