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="300,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" />
33 <screen name="serviceScan" position="150,100" size="300,200" title="Service Scan">
34 <widget name="scan_progress" position="10,10" size="280,50" />
35 <widget name="scan_state" position="10,60" size="280,30" />
36 <widget name="okbutton" position="10,100" size="280,40" />
43 def parsePosition(str):
45 return ePoint(int(x), int(y))
49 return eSize(int(x), int(y))
51 def applyAttributes(guiObject, node):
53 for p in range(node.attributes.length):
54 a = node.attributes.item(p)
56 # convert to string (was: unicode)
58 # TODO: proper UTF8 translation?! (for value)
59 # TODO: localization? as in e1?
63 if attrib == 'position':
64 guiObject.move(parsePosition(value))
65 elif attrib == 'size':
66 guiObject.resize(parseSize(value))
67 elif attrib == 'title':
68 guiObject.setTitle(value)
69 elif attrib != 'name':
70 print "unsupported attribute " + attrib + "=" + value
72 def applyGUIskin(screen, parent, skin, name):
76 # first, find the corresponding screen element
77 skin = dom.getElementsByTagName("skin")[0]
78 screens = skin.getElementsByTagName("screen")
81 if x.getAttribute('name') == name:
84 assert myscreen != None, "no skin for screen '" + name + "' found!"
86 applyAttributes(parent, myscreen)
88 # now walk all widgets
89 for widget in myscreen.getElementsByTagName("widget"):
90 wname = widget.getAttribute('name')
92 print "widget has no name!"
95 # get corresponding gui object
97 guiObject = screen[wname].instance
99 raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
101 applyAttributes(guiObject, widget)