1 from Renderer import Renderer
2 from enigma import eListbox
4 # the listbox renderer is the listbox, but no listbox content.
5 # the content will be provided by the source (or converter).
7 # the source should emit the 'changed' signal whenever
8 # it has a new listbox content.
10 # the source needs to have the 'content' property for the
11 # used listbox content
13 # it should expose exactly the non-content related functions
14 # of the eListbox class. more or less.
16 class Listbox(Renderer, object):
18 Renderer.__init__(self)
20 self.__wrap_around = False
21 self.__selection_enabled = True
25 def contentChanged(self):
26 self.content = self.source.content
28 def setContent(self, content):
29 self.__content = content
30 if self.instance is not None:
31 self.instance.setContent(self.__content)
33 content = property(lambda self: self.__content, setContent)
35 def postWidgetCreate(self, instance):
36 if self.__content is not None:
37 instance.setContent(self.__content)
38 instance.selectionChanged.get().append(self.selectionChanged)
39 self.wrap_around = self.wrap_around # trigger
40 self.selection_enabled = self.selection_enabled # trigger
42 def setWrapAround(self, wrap_around):
43 self.__wrap_around = wrap_around
44 if self.instance is not None:
45 self.instance.setWrapAround(self.__wrap_around)
47 wrap_around = property(lambda self: self.__wrap_around, setWrapAround)
49 def selectionChanged(self):
50 self.source.selectionChanged(self.index)
53 if self.instance is None:
55 return self.instance.getCurrentIndex()
57 def moveToIndex(self, index):
58 if self.instance is None:
60 self.instance.moveSelectionTo(index)
62 index = property(getIndex, moveToIndex)
64 def move(self, direction):
65 if self.instance is not None:
66 self.instance.moveSelection(direction)
68 def setSelectionEnabled(self, enabled):
69 self.__selection_enabled = enabled
70 if self.instance is not None:
71 self.instance.setSelectionEnable(enabled)
73 selection_enabled = property(lambda self: self.__selection_enabled, setSelectionEnabled)
75 def changed(self, what):
76 self.content = self.source.content