1 from HTMLComponent import *
2 from GUIComponent import *
4 from enigma import eListboxPythonStringContent, eListbox
6 class MenuList(HTMLComponent, GUIComponent):
7 def __init__(self, list, enableWrapAround=False):
8 GUIComponent.__init__(self)
10 self.l = eListboxPythonStringContent()
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)
29 def selectionChanged(self):
30 for f in self.onSelectionChanged:
33 def getSelectedIndex(self):
34 return self.l.getCurrentSelectionIndex()
36 def setList(self, list):
38 self.l.setList(self.list)
40 def moveToIndex(self, idx):
41 self.instance.moveSelectionTo(idx)
44 if self.instance is not None:
45 self.instance.moveSelection(self.instance.pageUp)
48 if self.instance is not None:
49 self.instance.moveSelection(self.instance.pageDown)
52 if self.instance is not None:
53 self.instance.moveSelection(self.instance.moveUp)
56 if self.instance is not None:
57 self.instance.moveSelection(self.instance.moveDown)
59 def selectionEnabled(self, enabled):
60 if self.instance is not None:
61 self.instance.setSelectionEnable(enabled)