3 from xml.dom import EMPTY_NAMESPACE
13 dom = xml.dom.minidom.parseString(
16 <screen name="mainMenu" position="300,100" size="300,300" title="real main menu">
17 <widget name="okbutton" position="10,190" size="280,50" />
18 <widget name="title" position="10,10" size="280,20" />
19 <widget name="menu" position="10,30" size="280,140" />
21 <screen name="clockDisplay" position="300,100" size="300,300">
22 <widget name="okbutton" position="10,10" size="280,40" />
23 <widget name="title" position="10,120" size="280,50" />
24 <widget name="theClock" position="10,60" size="280,50" />
26 <screen name="infoBar" position="100,100" size="500,400" title="InfoBar">
27 <widget name="channelSwitcher" position="10,190" size="280,50" />
29 <screen name="channelSelection" position="300,100" size="300,300" title="Channel Selection">
30 <widget name="okbutton" position="10,190" size="280,50" />
31 <widget name="list" position="10,30" size="280,140" />
38 def parsePosition(str):
40 return ePoint(int(x), int(y))
44 return eSize(int(x), int(y))
46 def applyAttributes(guiObject, node):
48 for p in range(node.attributes.length):
49 a = node.attributes.item(p)
51 # convert to string (was: unicode)
53 # TODO: proper UTF8 translation?! (for value)
54 # TODO: localization? as in e1?
58 if attrib == 'position':
59 guiObject.move(parsePosition(value))
60 elif attrib == 'size':
61 guiObject.resize(parseSize(value))
62 elif attrib == 'title':
63 guiObject.setTitle(value)
64 elif attrib != 'name':
65 print "unsupported attribute " + attrib + "=" + value
67 def applyGUIskin(screen, parent, skin, name):
71 # first, find the corresponding screen element
72 skin = dom.getElementsByTagName("skin")[0]
73 screens = skin.getElementsByTagName("screen")
76 if x.getAttribute('name') == name:
79 assert myscreen != None, "no skin for screen '" + name + "' found!"
81 applyAttributes(parent, myscreen)
83 # now walk all widgets
84 for widget in myscreen.getElementsByTagName("widget"):
85 wname = widget.getAttribute('name')
87 print "widget has no name!"
90 # get corresponding gui object
92 guiObject = screen.data[wname]["instance"]
94 raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
96 applyAttributes(guiObject, widget)