first step for skin support
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 13 Jan 2005 00:02:15 +0000 (00:02 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 13 Jan 2005 00:02:15 +0000 (00:02 +0000)
components.py
mytest.py
skin.py

index e66e43b1818c7dd28535f0f804d50cbdbf2e5887..315ae44c0c54efbe640303fe4157131fde17817f 100644 (file)
@@ -35,9 +35,7 @@ class GUIComponent:
        def GUIcreate(self, priv, parent, skindata):
                i = self.GUIcreateInstance(self, parent, skindata)
                priv["instance"] = i
-               print str(self) + " notifier list before " + str(self.notifier)
                self.notifier.append(i)
-               print str(self) + " notifier list now " + str(self.notifier)
                if self.notifierAdded:
                        self.notifierAdded(i)
 
@@ -53,7 +51,6 @@ class VariableText:
        def setText(self, text):
                if self.message != text:
                        self.message = text
-                       print self.notifier
                        for x in self.notifier:
                                x.setText(self.message)
 
index 723de54d21dea995d17ac4bc8b6991845048b1ff..e5dd7e964c5a3ded0eb201e83b112c6cc4b6cbc7 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -66,7 +66,6 @@ def test():
        wnd.setTitle("python")
        wnd.move(ePoint(300, 100))
        wnd.resize(eSize(300, 300))
-       wnd.show()
 
        gui = GUIOutputDevice()
        gui.parent = wnd
@@ -108,6 +107,8 @@ def test():
 #      button.move(ePoint(200, 10))
 #      button.resize(eSize(80, 50)) 
 
+       wnd.show()
+
        for x in range(200):
                time.sleep(0.1)
                components["clock"].doClock()
@@ -115,7 +116,7 @@ def test():
                        r = 200 - x
                else:
                        r = x
-#              components["$002"]["okbutton"].setValue(r)
+               components["$002"]["okbutton"].setValue(r)
                desktop.paint()
        
 #      
@@ -126,6 +127,7 @@ def test():
 #      print "delete wnd"
 #      del wnd
 #      print "bye"
+
        
        
        return 0
diff --git a/skin.py b/skin.py
index 415f3412bc17955f49c20817fb668a1ff049b930..5d482fdb32f0ab4b751f22f2a331a6aa5626fb47 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -1,5 +1,6 @@
 from enigma import *
 import xml.dom.minidom
+from xml.dom import EMPTY_NAMESPACE
 
 def dump(x, i=0):
        print " " * i + str(x)
@@ -10,19 +11,54 @@ def dump(x, i=0):
                None
 
 dom = xml.dom.minidom.parseString(
-       "<screen name=\"clockDialog\"> \
+       "<screen name=\"clockDialog\" position=\"300,100\" size=\"300,300\"> \
                <widget name=\"okbutton\" position=\"10,10\" size=\"280,40\" /> \
                <widget name=\"theClock\" position=\"10,60\" size=\"280,50\" /> \
                <widget name=\"title\" position=\"10,120\" size=\"280,50\" /> \
        </screen>")
 
-def applyGUIskin(screen, skin, name):
-       dump(dom[screen])
-       screen.data["okbutton"]["instance"].move(ePoint(10, 10))
-       screen.data["okbutton"]["instance"].resize(eSize(280, 40))
+def parsePosition(str):
+       x, y = str.split(',')
+       return ePoint(int(x), int(y))
+
+def parseSize(str):
+       x, y = str.split(',')
+       return eSize(int(x), int(y))
 
-       screen.data["theClock"]["instance"].move(ePoint(10, 60))
-       screen.data["theClock"]["instance"].resize(eSize(280, 50))
+def applyAttributes(guiObject, node):
+       # walk all attributes
+       for p in range(node.attributes.length):
+               a = node.attributes.item(p)
+               
+               # and set attributes
+               if a.name == 'position':
+                       guiObject.move(parsePosition(a.value))
+               elif a.name == 'size':
+                       guiObject.resize(parseSize(a.value))
+               elif a.name != 'name':
+                       print "unsupported attribute " + a.name
 
-       screen.data["title"]["instance"].move(ePoint(10, 120))
-       screen.data["title"]["instance"].resize(eSize(280, 50))
+def applyGUIskin(screen, skin, name):
+       
+       myscreen = None
+       
+       # first, find the corresponding screen element
+       screens = dom.getElementsByTagName("screen")
+       for x in screens:
+               if x.getAttribute('name') == name:
+                       myscreen = x
+       
+       if myscreen == None:
+               print "no skin for screen " + name + " found!"
+               return;
+       
+       # now walk all widgets
+       for widget in myscreen.getElementsByTagName("widget"):
+               name = widget.getAttribute('name')
+               if name == None:
+                       print "widget has no name!"
+                       continue
+               
+               # get corresponding gui object
+               guiObject = screen.data[name]["instance"]
+               applyAttributes(guiObject, widget)