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="80,350" size="540,150" title="InfoBar">
27 <widget name="CurrentTime" position="10,10" size="40,30" />
28 <widget name="ServiceName" position="50,20" size="200,30" />
29 <widget name="Event_Now" position="100,40" size="300,30" />
30 <widget name="Event_Next" position="100,90" size="300,30" />
31 <widget name="Event_Now_Duration" position="440,40" size="80,30" />
32 <widget name="Event_Next_Duration" position="440,90" size="80,30" />
34 <screen name="channelSelection" position="100,80" size="500,240" title="Channel Selection">
35 <widget name="list" position="20,50" size="300,150" />
36 <widget name="okbutton" position="340,50" size="140,30" />
38 <screen name="serviceScan" position="150,100" size="300,200" title="Service Scan">
39 <widget name="scan_progress" position="10,10" size="280,50" />
40 <widget name="scan_state" position="10,60" size="280,30" />
41 <widget name="okbutton" position="10,100" size="280,40" />
48 def parsePosition(str):
50 return ePoint(int(x), int(y))
54 return eSize(int(x), int(y))
56 def applyAttributes(guiObject, node):
58 for p in range(node.attributes.length):
59 a = node.attributes.item(p)
61 # convert to string (was: unicode)
63 # TODO: proper UTF8 translation?! (for value)
64 # TODO: localization? as in e1?
68 if attrib == 'position':
69 guiObject.move(parsePosition(value))
70 elif attrib == 'size':
71 guiObject.resize(parseSize(value))
72 elif attrib == 'title':
73 guiObject.setTitle(value)
74 elif attrib != 'name':
75 print "unsupported attribute " + attrib + "=" + value
77 def applyGUIskin(screen, parent, skin, name):
81 # first, find the corresponding screen element
82 skin = dom.getElementsByTagName("skin")[0]
83 screens = skin.getElementsByTagName("screen")
86 if x.getAttribute('name') == name:
89 assert myscreen != None, "no skin for screen '" + name + "' found!"
91 applyAttributes(parent, myscreen)
93 # now walk all widgets
94 for widget in myscreen.getElementsByTagName("widget"):
95 wname = widget.getAttribute('name')
97 print "widget has no name!"
100 # get corresponding gui object
102 guiObject = screen[wname].instance
104 raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
106 applyAttributes(guiObject, widget)