3 from xml.dom import EMPTY_NAMESPACE
13 dom = xml.dom.minidom.parseString(
16 <screen name="testDialog">
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="mainMenu" position="300,100" size="300,300">
27 <widget name="title" position="10,10" size="280,80" />
28 <widget name="okbutton" position="10,190" size="280,50" />
35 def parsePosition(str):
37 return ePoint(int(x), int(y))
41 return eSize(int(x), int(y))
43 def applyAttributes(guiObject, node):
45 for p in range(node.attributes.length):
46 a = node.attributes.item(p)
49 if a.name == 'position':
50 guiObject.move(parsePosition(a.value))
51 elif a.name == 'size':
52 guiObject.resize(parseSize(a.value))
53 elif a.name != 'name':
54 print "unsupported attribute " + a.name
56 def applyGUIskin(screen, skin, name):
60 # first, find the corresponding screen element
61 skin = dom.getElementsByTagName("skin")[0]
62 screens = skin.getElementsByTagName("screen")
65 if x.getAttribute('name') == name:
68 assert myscreen != None, "no skin for screen '" + name + "' found!"
70 # now walk all widgets
71 for widget in myscreen.getElementsByTagName("widget"):
72 wname = widget.getAttribute('name')
74 print "widget has no name!"
77 # get corresponding gui object
79 guiObject = screen.data[wname]["instance"]
81 raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
83 applyAttributes(guiObject, widget)