From: Felix Domke Date: Thu, 13 Jan 2005 00:02:15 +0000 (+0000) Subject: first step for skin support X-Git-Tag: 2.6.0~5948 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/47d24e1d25002485f1cb90f1682b4bc3070cad0b first step for skin support --- diff --git a/components.py b/components.py index e66e43b1..315ae44c 100644 --- a/components.py +++ b/components.py @@ -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) diff --git a/mytest.py b/mytest.py index 723de54d..e5dd7e96 100644 --- 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 415f3412..5d482fdb 100644 --- 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( - " \ + " \ \ \ \ ") -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)