3 from xml.dom import EMPTY_NAMESPACE
13 dom = xml.dom.minidom.parseString(
16 <screen name="testDialog">
17 <widget name="okbutton" position="10,120" size="280,40" />
18 <widget name="title" position="10,10" size="280,20" />
19 <widget name="menu" position="10,30" size="280,90" />
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" />
31 def parsePosition(str):
33 return ePoint(int(x), int(y))
37 return eSize(int(x), int(y))
39 def applyAttributes(guiObject, node):
41 for p in range(node.attributes.length):
42 a = node.attributes.item(p)
45 if a.name == 'position':
46 guiObject.move(parsePosition(a.value))
47 elif a.name == 'size':
48 guiObject.resize(parseSize(a.value))
49 elif a.name != 'name':
50 print "unsupported attribute " + a.name
52 def applyGUIskin(screen, skin, name):
56 # first, find the corresponding screen element
57 skin = dom.getElementsByTagName("skin")[0]
58 screens = skin.getElementsByTagName("screen")
61 if x.getAttribute('name') == name:
64 assert myscreen != None, "no skin for screen " + name + " found!"
66 print "ok, found screen.."
68 # now walk all widgets
69 for widget in myscreen.getElementsByTagName("widget"):
70 name = widget.getAttribute('name')
72 print "widget has no name!"
75 # get corresponding gui object
76 guiObject = screen.data[name]["instance"]
77 applyAttributes(guiObject, widget)