aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Renderer
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/Components/Renderer')
-rw-r--r--lib/python/Components/Renderer/Label.py9
-rw-r--r--lib/python/Components/Renderer/Listbox.py79
-rw-r--r--lib/python/Components/Renderer/Makefile.am4
-rw-r--r--lib/python/Components/Renderer/Progress.py11
-rw-r--r--lib/python/Components/Renderer/Renderer.py7
5 files changed, 96 insertions, 14 deletions
diff --git a/lib/python/Components/Renderer/Label.py b/lib/python/Components/Renderer/Label.py
index 02acb938..1d06a214 100644
--- a/lib/python/Components/Renderer/Label.py
+++ b/lib/python/Components/Renderer/Label.py
@@ -1,18 +1,17 @@
from Components.VariableText import VariableText
-from Components.GUIComponent import GUIComponent
+from Renderer import Renderer
from enigma import eLabel
-class Label(VariableText, GUIComponent):
+class Label(VariableText, Renderer):
def __init__(self):
- GUIComponent.__init__(self)
+ Renderer.__init__(self)
VariableText.__init__(self)
GUI_WIDGET = eLabel
def connect(self, source):
- source.changed.listen(self.changed)
- self.source = source
+ Renderer.connect(self, source)
self.changed()
def changed(self):
diff --git a/lib/python/Components/Renderer/Listbox.py b/lib/python/Components/Renderer/Listbox.py
new file mode 100644
index 00000000..fb787bfa
--- /dev/null
+++ b/lib/python/Components/Renderer/Listbox.py
@@ -0,0 +1,79 @@
+from Components.VariableText import VariableText
+from Renderer import Renderer
+from Tools.Event import Event
+
+from enigma import eListbox
+
+# the listbox renderer is the listbox, but no listbox content
+# the content will be provided by the source (or converter).
+
+# the source should emit the 'changed' signal whenever
+# it has a new listbox content.
+
+# the source needs to have the 'content' property for the
+# used listbox content
+
+# it should expose exactly the non-content related functions
+# of the eListbox class. more or less.
+
+class Listbox(Renderer, object):
+ def __init__(self):
+ Renderer.__init__(self)
+ self.__content = None
+ self.__wrap_around = False
+ self.__selection_enabled = True
+
+ GUI_WIDGET = eListbox
+
+ def contentChanged(self):
+ self.content = self.source.content
+
+ def setContent(self, content):
+ self.__content = content
+ if self.instance is not None:
+ self.instance.setContent(self.__content)
+
+ content = property(lambda self: self.__content, setContent)
+
+ def postWidgetCreate(self, instance):
+ if self.__content is not None:
+ instance.setContent(self.__content)
+ instance.selectionChanged.get().append(self.selectionChanged)
+ self.wrap_around = self.wrap_around # trigger
+ self.selection_enabled = self.selection_enabled # trigger
+
+ def setWrapAround(self, wrap_around):
+ self.__wrap_around = wrap_around
+ if self.instance is not None:
+ self.instance.setWrapAround(self.__wrap_around)
+
+ wrap_around = property(lambda self: self.__wrap_around, setWrapAround)
+
+ def selectionChanged(self):
+ self.upstream_elements.selectionChanged(self.index)
+
+ def getIndex(self):
+ if self.instance is None:
+ return None
+ return self.instance.getCurrentIndex()
+
+ def moveToIndex(self, index):
+ if self.instance is None:
+ return
+ self.instance.moveSelectionTo(index)
+
+ index = property(getIndex, moveToIndex)
+
+ def move(self, direction):
+ if self.instance is not None:
+ self.instance.moveSelection(direction)
+
+ def setSelectionEnabled(self, enabled):
+ self.__selection_enabled = enabled
+ if self.instance is not None:
+ self.instance.setSelectionEnable(enabled)
+
+ selection_enabled = property(lambda self: self.__selection_enabled, setSelectionEnabled)
+
+ def changed(self):
+ self.content = self.source.content
diff --git a/lib/python/Components/Renderer/Makefile.am b/lib/python/Components/Renderer/Makefile.am
index 3040d72f..a8ca2939 100644
--- a/lib/python/Components/Renderer/Makefile.am
+++ b/lib/python/Components/Renderer/Makefile.am
@@ -1,4 +1,6 @@
installdir = $(LIBDIR)/enigma2/python/Components/Renderer
install_PYTHON = \
- __init__.py Label.py Progress.py
+ __init__.py Label.py Progress.py Listbox.py Renderer.py
+
+
diff --git a/lib/python/Components/Renderer/Progress.py b/lib/python/Components/Renderer/Progress.py
index b8534287..9caea5e5 100644
--- a/lib/python/Components/Renderer/Progress.py
+++ b/lib/python/Components/Renderer/Progress.py
@@ -1,22 +1,17 @@
from Components.VariableValue import VariableValue
-from Components.GUIComponent import GUIComponent
+from Renderer import Renderer
from enigma import eSlider
-class Progress(VariableValue, GUIComponent):
+class Progress(VariableValue, Renderer):
def __init__(self):
- GUIComponent.__init__(self)
+ Renderer.__init__(self)
VariableValue.__init__(self)
self.__start = 0
self.__end = 100
GUI_WIDGET = eSlider
- def connect(self, source):
- source.changed.listen(self.changed)
- self.source = source
- self.changed()
-
def changed(self):
range = self.source.range or 100
value = self.source.value
diff --git a/lib/python/Components/Renderer/Renderer.py b/lib/python/Components/Renderer/Renderer.py
new file mode 100644
index 00000000..373aa02c
--- /dev/null
+++ b/lib/python/Components/Renderer/Renderer.py
@@ -0,0 +1,7 @@
+from Components.GUIComponent import GUIComponent
+from Components.Element import Element
+
+class Renderer(GUIComponent, Element):
+ def __init__(self):
+ Element.__init__(self)
+ GUIComponent.__init__(self)