1 from Components.VariableText import VariableText
2 from Renderer import Renderer
3 from Tools.Event import Event
5 from enigma import eListbox
7 # the listbox renderer is the listbox, but no listbox content
8 # the content will be provided by the source (or converter).
10 # the source should emit the 'changed' signal whenever
11 # it has a new listbox content.
13 # the source needs to have the 'content' property for the
14 # used listbox content
16 # it should expose exactly the non-content related functions
17 # of the eListbox class. more or less.
19 class Listbox(Renderer, object):
21 Renderer.__init__(self)
23 self.__wrap_around = False
24 self.__selection_enabled = True
28 def contentChanged(self):
29 self.content = self.source.content
31 def setContent(self, content):
32 self.__content = content
33 if self.instance is not None:
34 self.instance.setContent(self.__content)
36 content = property(lambda self: self.__content, setContent)
38 def postWidgetCreate(self, instance):
39 if self.__content is not None:
40 instance.setContent(self.__content)
41 instance.selectionChanged.get().append(self.selectionChanged)
42 self.wrap_around = self.wrap_around # trigger
43 self.selection_enabled = self.selection_enabled # trigger
45 def setWrapAround(self, wrap_around):
46 self.__wrap_around = wrap_around
47 if self.instance is not None:
48 self.instance.setWrapAround(self.__wrap_around)
50 wrap_around = property(lambda self: self.__wrap_around, setWrapAround)
52 def selectionChanged(self):
53 self.source.selectionChanged(self.index)
56 if self.instance is None:
58 return self.instance.getCurrentIndex()
60 def moveToIndex(self, index):
61 if self.instance is None:
63 self.instance.moveSelectionTo(index)
65 index = property(getIndex, moveToIndex)
67 def move(self, direction):
68 if self.instance is not None:
69 self.instance.moveSelection(direction)
71 def setSelectionEnabled(self, enabled):
72 self.__selection_enabled = enabled
73 if self.instance is not None:
74 self.instance.setSelectionEnable(enabled)
76 selection_enabled = property(lambda self: self.__selection_enabled, setSelectionEnabled)
78 def changed(self, what):
79 self.content = self.source.content