3 from xml.dom import EMPTY_NAMESPACE
13 dom = xml.dom.minidom.parseString(
16 <screen name="testDialog">
17 <widget name="okbutton" position="10,10" size="280,40" />
18 <widget name="title" position="10,120" size="280,50" />
20 <screen name="clockDisplay" position="300,100" size="300,300">
21 <widget name="okbutton" position="10,10" size="280,40" />
22 <widget name="title" position="10,120" size="280,50" />
23 <widget name="theClock" position="10,60" size="280,50" />
30 def parsePosition(str):
32 return ePoint(int(x), int(y))
36 return eSize(int(x), int(y))
38 def applyAttributes(guiObject, node):
40 for p in range(node.attributes.length):
41 a = node.attributes.item(p)
44 if a.name == 'position':
45 guiObject.move(parsePosition(a.value))
46 elif a.name == 'size':
47 guiObject.resize(parseSize(a.value))
48 elif a.name != 'name':
49 print "unsupported attribute " + a.name
51 def applyGUIskin(screen, skin, name):
55 # first, find the corresponding screen element
56 skin = dom.getElementsByTagName("skin")[0]
57 screens = skin.getElementsByTagName("screen")
60 if x.getAttribute('name') == name:
63 assert myscreen != None, "no skin for screen " + name + " found!"
65 print "ok, found screen.."
67 # now walk all widgets
68 for widget in myscreen.getElementsByTagName("widget"):
69 name = widget.getAttribute('name')
71 print "widget has no name!"
74 # get corresponding gui object
75 guiObject = screen.data[name]["instance"]
76 applyAttributes(guiObject, widget)