fix typo
[enigma2.git] / lib / python / Components / MenuList.py
1 from HTMLComponent import *
2 from GUIComponent import *
3
4 from enigma import eListboxPythonStringContent, eListbox
5
6 class MenuList(HTMLComponent, GUIComponent):
7         def __init__(self, list, enableWrapAround=False):
8                 GUIComponent.__init__(self)
9                 self.list = list
10                 self.l = eListboxPythonStringContent()
11                 self.l.setList(self.list)
12                 self.onSelectionChanged = [ ]
13                 self.enableWrapAround = enableWrapAround
14         
15         def getCurrent(self):
16                 return self.l.getCurrentSelection()
17
18         GUI_WIDGET = eListbox
19         
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)
25         
26         def preWidgetRemove(self, instance):
27                 instance.setContent(None)
28
29         def selectionChanged(self):
30                 for f in self.onSelectionChanged:
31                         f()
32
33         def setList(self, list):
34                 self.list = list
35                 self.l.setList(self.list)
36
37         def moveToIndex(self, idx):
38                 self.instance.moveSelectionTo(idx)
39
40         def pageUp(self):
41                 if self.instance is not None:
42                         self.instance.moveSelection(self.instance.pageUp)
43                 
44         def pageDown(self):
45                 if self.instance is not None:
46                         self.instance.moveSelection(self.instance.pageDown)
47                         
48         def up(self):
49                 if self.instance is not None:
50                         self.instance.moveSelection(self.instance.moveUp)
51                 
52         def down(self):
53                 if self.instance is not None:
54                         self.instance.moveSelection(self.instance.moveDown)
55                         
56         def selectionEnabled(self, enabled):
57                 if self.instance is not None:
58                         self.instance.setSelectionEnable(enabled)