aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/Components')
-rw-r--r--lib/python/Components/Button.py2
-rw-r--r--lib/python/Components/Clock.py2
-rw-r--r--lib/python/Components/ConfigList.py2
-rw-r--r--lib/python/Components/GUIComponent.py11
-rw-r--r--lib/python/Components/GUISkin.py70
-rw-r--r--lib/python/Components/Header.py2
-rw-r--r--lib/python/Components/Label.py6
-rw-r--r--lib/python/Components/MenuList.py2
-rw-r--r--lib/python/Components/PerServiceDisplay.py2
-rw-r--r--lib/python/Components/ProgressBar.py2
-rw-r--r--lib/python/Components/ServiceList.py2
-rw-r--r--lib/python/Components/TextInput.py31
-rw-r--r--lib/python/Components/TimeInput.py18
-rw-r--r--lib/python/Components/TimerList.py2
-rw-r--r--lib/python/Components/VariableText.py6
-rw-r--r--lib/python/Components/VariableValue.py6
-rw-r--r--lib/python/Components/VolumeBar.py2
17 files changed, 49 insertions, 119 deletions
diff --git a/lib/python/Components/Button.py b/lib/python/Components/Button.py
index d773b2c1..d9226b6d 100644
--- a/lib/python/Components/Button.py
+++ b/lib/python/Components/Button.py
@@ -29,7 +29,7 @@ class Button(HTMLComponent, GUIComponent, VariableText):
return "<input type=\"submit\" text=\"" + self.getText() + "\">\n"
# GUI:
- def createWidget(self, parent, skindata):
+ def createWidget(self, parent):
g = eButton(parent)
g.selected.get().append(self.push)
return g
diff --git a/lib/python/Components/Clock.py b/lib/python/Components/Clock.py
index 36e06942..3beed551 100644
--- a/lib/python/Components/Clock.py
+++ b/lib/python/Components/Clock.py
@@ -24,7 +24,7 @@ class Clock(HTMLComponent, GUIComponent, VariableText):
self.setText("%2d:%02d:%02d" % (t[3], t[4], t[5]))
# realisierung als GUI
- def createWidget(self, parent, skindata):
+ def createWidget(self, parent):
return eLabel(parent)
def removeWidget(self, w):
diff --git a/lib/python/Components/ConfigList.py b/lib/python/Components/ConfigList.py
index a2bdcb0b..35ea093c 100644
--- a/lib/python/Components/ConfigList.py
+++ b/lib/python/Components/ConfigList.py
@@ -22,7 +22,7 @@ class ConfigList(HTMLComponent, GUIComponent):
def invalidateCurrent(self):
self.l.invalidateEntry(self.l.getCurrentSelectionIndex())
- def GUIcreate(self, parent, skindata):
+ def GUIcreate(self, parent):
self.instance = eListbox(parent)
self.instance.setContent(self.l)
diff --git a/lib/python/Components/GUIComponent.py b/lib/python/Components/GUIComponent.py
index bcd99d24..fee9341c 100644
--- a/lib/python/Components/GUIComponent.py
+++ b/lib/python/Components/GUIComponent.py
@@ -1,12 +1,17 @@
+import skin
+
class GUIComponent:
""" GUI component """
-
+
def __init__(self):
pass
-
+
def execBegin(self):
pass
def execEnd(self):
pass
-
+
+ # this works only with normal widgets - if you don't have self.instance, override this.
+ def applySkin(self, desktop):
+ skin.applyAllAttributes(self.instance, desktop, self.skinAttributes)
diff --git a/lib/python/Components/GUISkin.py b/lib/python/Components/GUISkin.py
index b918e908..982cce31 100644
--- a/lib/python/Components/GUISkin.py
+++ b/lib/python/Components/GUISkin.py
@@ -1,65 +1,31 @@
from GUIComponent import *
+from skin import applyAllAttributes
class GUISkin:
+ __module__ = __name__
+
def __init__(self):
+ self.onLayoutFinish = [ ]
pass
-
- def createGUIScreen(self, parent):
+
+ def createGUIScreen(self, parent, desktop):
for (name, val) in self.items():
if isinstance(val, GUIComponent):
- val.GUIcreate(parent, None)
-
+ val.GUIcreate(parent)
+ val.applySkin(desktop)
+
+ for w in self.additionalWidgets:
+ w.instance = w.widget(parent)
+ w.instance.thisown = 0
+ applyAllAttributes(w.instance, desktop, w.skinAttributes)
+
+ for f in self.onLayoutFinish:
+ exec(f) in globals(), locals()
+
def deleteGUIScreen(self):
for (name, val) in self.items():
if isinstance(val, GUIComponent):
val.GUIdelete()
- try:
- val.fix()
- except:
- pass
-
- # DIESER KOMMENTAR IST NUTZLOS UND MITTLERWEILE VERALTET! (glaub ich)
- # BITTE NICHT LESEN!
- # note: you'll probably run into this assert. if this happens, don't panic!
- # yes, it's evil. I told you that programming in python is just fun, and
- # suddently, you have to care about things you don't even know.
- #
- # but calm down, the solution is easy, at least on paper:
- #
- # Each Component, which is a GUIComponent, owns references to each
- # instantiated eWidget (namely in screen.data[name]["instance"], in case
- # you care.)
- # on deleteGUIscreen, all eWidget *must* (!) be deleted (otherwise,
- # well, problems appear. I don't want to go into details too much,
- # but this would be a memory leak anyway.)
- # The assert beyond checks for that. It asserts that the corresponding
- # eWidget is about to be removed (i.e., that the refcount becomes 0 after
- # running deleteGUIscreen).
- # (You might wonder why the refcount is checked for 2 and not for 1 or 0 -
- # one reference is still hold by the local variable 'w', another one is
- # hold be the function argument to sys.getrefcount itself. So only if it's
- # 2 at this point, the object will be destroyed after leaving deleteGUIscreen.)
- #
- # Now, how to fix this problem? You're holding a reference somewhere. (References
- # can only be hold from Python, as eWidget itself isn't related to the c++
- # way of having refcounted objects. So it must be in python.)
- #
- # It could be possible that you're calling deleteGUIscreen trough a call of
- # a PSignal. For example, you could try to call screen.doClose() in response
- # to a Button::click. This will fail. (It wouldn't work anyway, as you would
- # remove a dialog while running it. It never worked - enigma1 just set a
- # per-mainloop variable on eWidget::close() to leave the exec()...)
- # That's why Session supports delayed closes. Just call Session.close() and
- # it will work.
- #
- # Another reason is that you just stored the data["instance"] somewhere. or
- # added it into a notifier list and didn't removed it.
- #
- # If you can't help yourself, just ask me. I'll be glad to help you out.
- # Sorry for not keeping this code foolproof. I really wanted to archive
- # that, but here I failed miserably. All I could do was to add this assert.
-# assert sys.getrefcount(w) == 2, "too many refs hold to " + str(w)
-
+
def close(self):
self.deleteGUIScreen()
-
diff --git a/lib/python/Components/Header.py b/lib/python/Components/Header.py
index 3ff6ab32..9f7be60e 100644
--- a/lib/python/Components/Header.py
+++ b/lib/python/Components/Header.py
@@ -14,7 +14,7 @@ class Header(HTMLComponent, GUIComponent, VariableText):
def produceHTML(self):
return "<h2>" + self.getText() + "</h2>\n"
- def createWidget(self, parent, skindata):
+ def createWidget(self, parent):
g = eLabel(parent)
return g
diff --git a/lib/python/Components/Label.py b/lib/python/Components/Label.py
index 609c6deb..7402d722 100644
--- a/lib/python/Components/Label.py
+++ b/lib/python/Components/Label.py
@@ -15,6 +15,10 @@ class Label(HTMLComponent, GUIComponent, VariableText):
return self.getText()
# GUI:
- def createWidget(self, parent, skindata):
+ def createWidget(self, parent):
return eLabel(parent)
+ def getSize(self):
+ s = self.instance.calculateSize()
+ return (s.width(), s.height())
+
diff --git a/lib/python/Components/MenuList.py b/lib/python/Components/MenuList.py
index 90cd3286..6fb33540 100644
--- a/lib/python/Components/MenuList.py
+++ b/lib/python/Components/MenuList.py
@@ -12,7 +12,7 @@ class MenuList(HTMLComponent, GUIComponent):
def getCurrent(self):
return self.l.getCurrentSelection()
- def GUIcreate(self, parent, skindata):
+ def GUIcreate(self, parent):
self.instance = eListbox(parent)
self.instance.setContent(self.l)
diff --git a/lib/python/Components/PerServiceDisplay.py b/lib/python/Components/PerServiceDisplay.py
index bd94318e..eab1e086 100644
--- a/lib/python/Components/PerServiceDisplay.py
+++ b/lib/python/Components/PerServiceDisplay.py
@@ -23,7 +23,7 @@ class PerServiceDisplay(GUIComponent, VariableText):
# call handler
self.eventmap[ev]()
- def createWidget(self, parent, skindata):
+ def createWidget(self, parent):
# by default, we use a label to display our data.
g = eLabel(parent)
return g
diff --git a/lib/python/Components/ProgressBar.py b/lib/python/Components/ProgressBar.py
index 0ae4868a..68824d5a 100644
--- a/lib/python/Components/ProgressBar.py
+++ b/lib/python/Components/ProgressBar.py
@@ -10,7 +10,7 @@ class ProgressBar(HTMLComponent, GUIComponent, VariableValue):
GUIComponent.__init__(self)
VariableValue.__init__(self)
- def createWidget(self, parent, skindata):
+ def createWidget(self, parent):
g = eSlider(parent)
g.setRange(0, 100)
return g
diff --git a/lib/python/Components/ServiceList.py b/lib/python/Components/ServiceList.py
index b1bd2170..1aa3d487 100644
--- a/lib/python/Components/ServiceList.py
+++ b/lib/python/Components/ServiceList.py
@@ -19,7 +19,7 @@ class ServiceList(HTMLComponent, GUIComponent):
def moveDown(self):
self.instance.moveSelection(self.instance.moveDown)
- def GUIcreate(self, parent, skindata):
+ def GUIcreate(self, parent):
self.instance = eListbox(parent)
self.instance.setContent(self.l)
diff --git a/lib/python/Components/TextInput.py b/lib/python/Components/TextInput.py
index 98b440c5..e69de29b 100644
--- a/lib/python/Components/TextInput.py
+++ b/lib/python/Components/TextInput.py
@@ -1,31 +0,0 @@
-from HTMLComponent import *
-from GUIComponent import *
-
-from tools import CONNECT, DISCONNECT
-
-from enigma import eInput, eInputContentString
-
-class TextInput(HTMLComponent, GUIComponent):
- def __init__(self):
- GUIComponent.__init__(self)
- self.content = eInputContentString()
-
- def contentChanged(self):
- print "content changed to %s!" % (self.getText())
-
- def getText(self):
- return self.content.getText()
-
- def setText(self, text):
- # TODO : support unicode!
- self.content.setText(str(text))
-
- def GUIcreate(self, parent, skindata):
- self.instance = eInput(parent)
- CONNECT(self.instance.changed, self.contentChanged)
- self.instance.setContent(self.content)
-
- def GUIdelete(self):
- DISCONNECT(self.instance.changed, self.contentChanged)
- self.instance.setContent(None)
- self.instance = None
diff --git a/lib/python/Components/TimeInput.py b/lib/python/Components/TimeInput.py
index c520fdf5..e69de29b 100644
--- a/lib/python/Components/TimeInput.py
+++ b/lib/python/Components/TimeInput.py
@@ -1,18 +0,0 @@
-from HTMLComponent import *
-from GUIComponent import *
-from VariableText import *
-
-from enigma import eInput, eInputContentNumber
-
-class TimeInput(HTMLComponent, GUIComponent):
- def __init__(self):
- GUIComponent.__init__(self)
- self.content = eInputContentNumber(12, 0, 15)
-
- def GUIcreate(self, parent, skindata):
- self.instance = eInput(parent)
- self.instance.setContent(self.content)
-
- def GUIdelete(self):
- self.instance.setContent(None)
- self.instance = None
diff --git a/lib/python/Components/TimerList.py b/lib/python/Components/TimerList.py
index 9ef7cc4b..18c5cb13 100644
--- a/lib/python/Components/TimerList.py
+++ b/lib/python/Components/TimerList.py
@@ -45,7 +45,7 @@ class TimerList(HTMLComponent, GUIComponent):
def getCurrent(self):
return self.l.getCurrentSelection()
- def GUIcreate(self, parent, skindata):
+ def GUIcreate(self, parent):
self.instance = eListbox(parent)
self.instance.setContent(self.l)
self.instance.setItemHeight(50)
diff --git a/lib/python/Components/VariableText.py b/lib/python/Components/VariableText.py
index 694355e7..76dc201a 100644
--- a/lib/python/Components/VariableText.py
+++ b/lib/python/Components/VariableText.py
@@ -1,3 +1,5 @@
+import skin
+
class VariableText:
"""VariableText can be used for components which have a variable text, based on any widget with setText call"""
@@ -13,8 +15,8 @@ class VariableText:
def getText(self):
return self.message
- def GUIcreate(self, parent, skindata):
- self.instance = self.createWidget(parent, skindata)
+ def GUIcreate(self, parent):
+ self.instance = self.createWidget(parent)
self.instance.setText(self.message)
def GUIdelete(self):
diff --git a/lib/python/Components/VariableValue.py b/lib/python/Components/VariableValue.py
index c94218fe..8f0cef4c 100644
--- a/lib/python/Components/VariableValue.py
+++ b/lib/python/Components/VariableValue.py
@@ -1,3 +1,5 @@
+import skin
+
class VariableValue:
"""VariableValue can be used for components which have a variable value (like eSlider), based on any widget with setValue call"""
@@ -13,8 +15,8 @@ class VariableValue:
def getValue(self):
return self.value
- def GUIcreate(self, parent, skindata):
- self.instance = self.createWidget(parent, skindata)
+ def GUIcreate(self, parent):
+ self.instance = self.createWidget(parent)
self.instance.setValue(self.value)
def GUIdelete(self):
diff --git a/lib/python/Components/VolumeBar.py b/lib/python/Components/VolumeBar.py
index 6eace42c..a6da5980 100644
--- a/lib/python/Components/VolumeBar.py
+++ b/lib/python/Components/VolumeBar.py
@@ -8,7 +8,7 @@ class VolumeBar(HTMLComponent, GUIComponent, VariableValue):
GUIComponent.__init__(self)
VariableValue.__init__(self)
- def createWidget(self, parent, skindata):
+ def createWidget(self, parent):
g = eSlider(parent)
g.setRange(0, 100)
return g