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" />
28 <widget name="ServiceName" position="50,20" size="200,30" />
29 <widget name="Event_Now" position="50,50" size="200,30" />
30 <widget name="Event_Next" position="50,80" size="200,30" />
32 <screen name="channelSelection" position="300,100" size="300,300" title="Channel Selection">
33 <widget name="okbutton" position="10,190" size="280,50" />
34 <widget name="list" position="10,30" size="280,140" />
36 <screen name="serviceScan" position="150,100" size="300,200" title="Service Scan">
37 <widget name="scan_progress" position="10,10" size="280,50" />
38 <widget name="scan_state" position="10,60" size="280,30" />
39 <widget name="okbutton" position="10,100" size="280,40" />
46 def parsePosition(str):
48 return ePoint(int(x), int(y))
52 return eSize(int(x), int(y))
54 def applyAttributes(guiObject, node):
56 for p in range(node.attributes.length):
57 a = node.attributes.item(p)
59 # convert to string (was: unicode)
61 # TODO: proper UTF8 translation?! (for value)
62 # TODO: localization? as in e1?
66 if attrib == 'position':
67 guiObject.move(parsePosition(value))
68 elif attrib == 'size':
69 guiObject.resize(parseSize(value))
70 elif attrib == 'title':
71 guiObject.setTitle(value)
72 elif attrib != 'name':
73 print "unsupported attribute " + attrib + "=" + value
75 def applyGUIskin(screen, parent, skin, name):
79 # first, find the corresponding screen element
80 skin = dom.getElementsByTagName("skin")[0]
81 screens = skin.getElementsByTagName("screen")
84 if x.getAttribute('name') == name:
87 assert myscreen != None, "no skin for screen '" + name + "' found!"
89 applyAttributes(parent, myscreen)
91 # now walk all widgets
92 for widget in myscreen.getElementsByTagName("widget"):
93 wname = widget.getAttribute('name')
95 print "widget has no name!"
98 # get corresponding gui object
100 guiObject = screen[wname].instance
102 raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
104 applyAttributes(guiObject, widget)