From: Felix Domke Date: Fri, 8 Jul 2005 16:41:35 +0000 (+0000) Subject: - skins are now loaded first and applied later X-Git-Tag: 2.6.0~5812 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/98c4b5bb004e9297bffa8e1c3572572741fda933 - skins are now loaded first and applied later - this allows use skin information to build special eWidgets, depending on skin - add "applet"-feature: code which is executed from skin - example: centering of messagebox --- 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 "\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 "

" + self.getText() + "

\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 diff --git a/lib/python/Screens/InfoBar.py b/lib/python/Screens/InfoBar.py index 5112a00d..ee09e577 100644 --- a/lib/python/Screens/InfoBar.py +++ b/lib/python/Screens/InfoBar.py @@ -6,6 +6,8 @@ from Components.Button import Button from Components.ServiceName import ServiceName from Components.EventInfo import EventInfo +from Screens.MessageBox import MessageBox + from enigma import * import time @@ -31,7 +33,7 @@ class InfoBar(Screen): "hide": self.hide, "toggleShow": self.toggleShow }) - self["okbutton"] = Button("mainMenu", [self.mainMenu]) +# self["okbutton"] = Button("mainMenu", [self.mainMenu]) self["CurrentTime"] = Clock() @@ -77,6 +79,9 @@ class InfoBar(Screen): self.servicelist.zap() def instantRecord(self): + self.session.open(MessageBox, "this would be an instant recording! do you really know what you're doing?!") + return + if self.recording != None: print "remove entry" self.session.nav.RecordTimer.removeEntry(self.recording) diff --git a/lib/python/Screens/Menu.py b/lib/python/Screens/Menu.py index c3809318..3b54577e 100644 --- a/lib/python/Screens/Menu.py +++ b/lib/python/Screens/Menu.py @@ -19,6 +19,8 @@ import xml.dom.minidom from xml.dom import EMPTY_NAMESPACE from skin import elementsWithTag +from Tools import XMLTools + # some screens def doGlobal(screen): screen["clock"] = Clock() @@ -74,13 +76,6 @@ mdom = xml.dom.minidom.parseString( """) -def getText(nodelist): - rc = "" - for node in nodelist: - if node.nodeType == node.TEXT_NODE: - rc = rc + node.data - return rc - def getValbyAttr(x, attr): for p in range(x.attributes.length): a = x.attributes.item(p) @@ -159,6 +154,7 @@ class Menu(Screen): self.session.open(clockDisplay, Clock()) def okbuttonClick(self): + print "okbuttonClick" selection = self["menu"].getCurrent() selection[1]() @@ -178,7 +174,7 @@ class Menu(Screen): def addItem(self, destList, node): ItemText = getValbyAttr(node, "text") if ItemText != "": #check for name - b = getText(node.childNodes) + b = XMLTools.mergeText(node.childNodes) if b != "": #check for function destList.append((ItemText,boundFunction(self.evalText,b))) else: diff --git a/lib/python/Screens/MessageBox.py b/lib/python/Screens/MessageBox.py new file mode 100644 index 00000000..bb6318be --- /dev/null +++ b/lib/python/Screens/MessageBox.py @@ -0,0 +1,15 @@ +from Screen import Screen +from Components.ActionMap import ActionMap +from Components.Label import Label + +class MessageBox(Screen): + def __init__(self, session, text): + Screen.__init__(self, session) + + self["text"] = Label(text) + + self["actions"] = ActionMap(["OkCancelActions"], + { + "cancel": self.close + }) + diff --git a/lib/python/Screens/__init__.py b/lib/python/Screens/__init__.py index fbd2c173..c91f5f57 100644 --- a/lib/python/Screens/__init__.py +++ b/lib/python/Screens/__init__.py @@ -1,4 +1,4 @@ __all__ = ["ChannelSelection", "ClockDisplay", "ConfigMenu", - "InfoBar", "Menu", "ScartLoopThrough", "Screen", "ServiceScan", + "InfoBar", "MessageBox", "Menu", "ScartLoopThrough", "Screen", "ServiceScan", "TimerEdit"] diff --git a/lib/python/Tools/XMLTools.py b/lib/python/Tools/XMLTools.py index aaab4677..05513622 100644 --- a/lib/python/Tools/XMLTools.py +++ b/lib/python/Tools/XMLTools.py @@ -15,3 +15,11 @@ def elementsWithTag(el, tag): continue if tag(x.tagName): yield x + +def mergeText(nodelist): + rc = "" + for node in nodelist: + if node.nodeType == node.TEXT_NODE: + rc = rc + node.data + return rc + diff --git a/mytest.py b/mytest.py index d6cfb1a2..01db6e65 100644 --- a/mytest.py +++ b/mytest.py @@ -10,7 +10,7 @@ import ServiceReference from Navigation import Navigation -from skin import applyGUIskin +from skin import readSkin, applyAllAttributes # A screen is a function which instanciates all components of a screen into a temporary component. # Thus, the global stuff is a screen, too. @@ -54,8 +54,8 @@ html = HTMLOutputDevice() class GUIOutputDevice(OutputDevice): parent = None - def create(self, comp): - comp.createGUIScreen(self.parent) + def create(self, comp, desktop): + comp.createGUIScreen(self.parent, desktop) class Session: def __init__(self): @@ -75,7 +75,7 @@ class Session: print sys.getrefcount(self.currentDialog) del self.currentDialog.instance - dump(self.currentDialog) +# dump(self.currentDialog) del self.currentDialog self.popCurrent() @@ -93,16 +93,20 @@ class Session: return screen(self, *arguments) def instantiateDialog(self, screen, *arguments): + # create dialog dlg = self.create(screen, arguments) + + # read skin data + readSkin(dlg, None, dlg.skinName, self.desktop) + + # create GUI view of this dialog assert self.desktop != None dlg.instance = eWindow(self.desktop) - + applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes) gui = GUIOutputDevice() gui.parent = dlg.instance - gui.create(dlg) - - applyGUIskin(dlg, None, dlg.skinName, self.desktop) - + gui.create(dlg, self.desktop) + return dlg def pushCurrent(self): diff --git a/skin.py b/skin.py index bc4931fb..57065076 100644 --- a/skin.py +++ b/skin.py @@ -2,7 +2,7 @@ from enigma import * import xml.dom.minidom from xml.dom import EMPTY_NAMESPACE -from Tools.XMLTools import elementsWithTag +from Tools.XMLTools import elementsWithTag, mergeText colorNames = dict() @@ -46,11 +46,12 @@ dom = xml.dom.minidom.parseString( - + """ """ + @@ -104,13 +105,38 @@ dom = xml.dom.minidom.parseString( - - - + + + + + + +# this should be factored out into some helper code, but currently demonstrated applets. +from enigma import eSize, ePoint + +orgwidth = self.instance.size().width() +orgpos = self.instance.position() +textsize = self["text"].getSize() + +# y size still must be fixed in font stuff... +textsize = (textsize[0], textsize[1] + 20) +wsize = (textsize[0] + 20, textsize[1] + 20) + +# resize +self.instance.resize(eSize(*wsize)) + +# resize label +self["text"].instance.resize(eSize(*textsize)) + +# center window +newwidth = wsize[0] +self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) + + """) def parsePosition(str): @@ -133,7 +159,7 @@ def parseColor(str): raise ("color '%s' must be #aarrggbb or valid named color" % (str)) return gRGB(int(str[1:], 0x10)) -def applyAttributes(guiObject, node, desktop): +def collectAttributes(skinAttributes, node): # walk all attributes for p in range(node.attributes.length): a = node.attributes.item(p) @@ -144,60 +170,70 @@ def applyAttributes(guiObject, node, desktop): # TODO: localization? as in e1? value = str(a.value) - # and set attributes - try: - if attrib == 'position': - guiObject.move(parsePosition(value)) - elif attrib == 'size': - guiObject.resize(parseSize(value)) - elif attrib == 'title': - guiObject.setTitle(value) - elif attrib == 'text': - guiObject.setText(value) - elif attrib == 'font': - guiObject.setFont(parseFont(value)) - elif attrib == "pixmap": - ptr = gPixmapPtr() - if loadPNG(ptr, value): - raise "loading PNG failed!" - x = ptr - ptr = ptr.__deref__() - desktop.makeCompatiblePixmap(ptr) - guiObject.setPixmap(ptr) -# guiObject.setPixmapFromFile(value) - elif attrib == "valign": - try: - guiObject.setVAlign( - { "top": guiObject.alignTop, - "center": guiObject.alignCenter, - "bottom": guiObject.alignBottom - }[value]) - except KeyError: - print "valign must be either top, center or bottom!" - elif attrib == "halign": + skinAttributes[attrib] = value + +def applySingleAttribute(guiObject, desktop, attrib, value): + # and set attributes + try: + if attrib == 'position': + guiObject.move(parsePosition(value)) + elif attrib == 'size': + guiObject.resize(parseSize(value)) + elif attrib == 'title': + guiObject.setTitle(value) + elif attrib == 'text': + guiObject.setText(value) + elif attrib == 'font': + guiObject.setFont(parseFont(value)) + elif attrib == "pixmap": + ptr = gPixmapPtr() + if loadPNG(ptr, value): + raise "loading PNG failed!" + x = ptr + ptr = ptr.__deref__() + desktop.makeCompatiblePixmap(ptr) + guiObject.setPixmap(ptr) + # guiObject.setPixmapFromFile(value) + elif attrib == "valign": + try: + guiObject.setVAlign( + { "top": guiObject.alignTop, + "center": guiObject.alignCenter, + "bottom": guiObject.alignBottom + }[value]) + except KeyError: + print "valign must be either top, center or bottom!" + elif attrib == "halign": + try: + guiObject.setHAlign( + { "left": guiObject.alignLeft, + "center": guiObject.alignCenter, + "right": guiObject.alignRight, + "block": guiObject.alignBlock + }[value]) + except KeyError: + print "halign must be either left, center, right or block!" + elif attrib == "flags": + flags = value.split(',') + for f in flags: try: - guiObject.setHAlign( - { "left": guiObject.alignLeft, - "center": guiObject.alignCenter, - "right": guiObject.alignRight, - "block": guiObject.alignBlock - }[value]) + fv = eWindow.__dict__[f] + guiObject.setFlag(fv) except KeyError: - print "halign must be either left, center, right or block!" - elif attrib == "flags": - flags = value.split(',') - for f in flags: - try: - fv = eWindow.__dict__[f] - guiObject.setFlag(fv) - except KeyError: - print "illegal flag %s!" % f - elif attrib == "backgroundColor": - guiObject.setBackgroundColor(parseColor(value)) - elif attrib != 'name': - print "unsupported attribute " + attrib + "=" + value - except AttributeError: - print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib) + print "illegal flag %s!" % f + elif attrib == "backgroundColor": + guiObject.setBackgroundColor(parseColor(value)) + elif attrib == "foregroundColor": + guiObject.setForegroundColor(parseColor(value)) + elif attrib != 'name': + print "unsupported attribute " + attrib + "=" + value + except int: +# AttributeError: + print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib) + +def applyAllAttributes(guiObject, desktop, attributes): + for (attrib, value) in attributes.items(): + applySingleAttribute(guiObject, desktop, attrib, value) def loadSkin(desktop): print "loading skin..." @@ -249,7 +285,7 @@ def loadSkin(desktop): eWindowStyleManager.getInstance(x) x.setStyle(style) -def applyGUIskin(screen, skin, name, desktop): +def readSkin(screen, skin, name, desktop): myscreen = None # first, find the corresponding screen element @@ -261,8 +297,11 @@ def applyGUIskin(screen, skin, name, desktop): del skin assert myscreen != None, "no skin for screen '" + name + "' found!" + + screen.skinAttributes = { } + collectAttributes(screen.skinAttributes, myscreen) - applyAttributes(screen.instance, myscreen, desktop) + screen.additionalWidgets = [ ] # now walk all widgets for widget in elementsWithTag(myscreen.childNodes, "widget"): @@ -273,20 +312,43 @@ def applyGUIskin(screen, skin, name, desktop): # get corresponding gui object try: - guiObject = screen[wname].instance + attributes = screen[wname].skinAttributes = { } except: raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!") - applyAttributes(guiObject, widget, desktop) + collectAttributes(attributes, widget) # now walk additional objects for widget in elementsWithTag(myscreen.childNodes, lambda x: x != "widget"): + if widget.tagName == "applet": + codeText = mergeText(widget.childNodes).strip() + type = widget.getAttribute('type') + + code = compile(codeText, "skin applet", "exec") + + if type == "onLayoutFinish": + screen.onLayoutFinish.append(code) + else: + raise str("applet type '%s' unknown!" % type) + + continue + + class additionalWidget: + pass + + w = additionalWidget() + if widget.tagName == "eLabel": - guiObject = eLabel(screen.instance) + w.widget = eLabel elif widget.tagName == "ePixmap": - guiObject = ePixmap(screen.instance) + w.widget = ePixmap else: raise str("unsupported stuff : %s" % widget.tagName) - applyAttributes(guiObject, widget, desktop ) - guiObject.thisown = 0 + w.skinAttributes = { } + collectAttributes(w.skinAttributes, widget) + + # applyAttributes(guiObject, widget, desktop) + # guiObject.thisown = 0 + print screen.additionalWidgets + screen.additionalWidgets.append(w)