Ejemplo n.º 1
0
 def fromXML(cls, element, parent):
     """Create the object from the XML element and attach it to the parent.
     """
     kw = loadxml.parseAttributes(element)
     items = list()
     for child in element.getchildren():
         assert child.tag == 'option'
         text = xml.sax.saxutils.unescape(child.text)
         childkw = loadxml.parseAttributes(child)
         items.append((text, child.attrib.get('id'), childkw))
     return cls(parent, items, **kw)
 def fromXML(cls, element, parent):
     '''Create the object from the XML element and attach it to the parent.
     '''
     kw = loadxml.parseAttributes(element)
     items = []
     for child in element.getchildren():
         assert child.tag == 'option'
         text = xml.sax.saxutils.unescape(child.text)
         childkw = loadxml.parseAttributes(child)
         items.append((text, child.attrib.get('id'), childkw))
     return cls(parent, items, **kw)
Ejemplo n.º 3
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.

        Create tabs for <tab> child tags.
        '''
        kw = loadxml.parseAttributes(element)
        obj = cls(parent, **kw)
        for child in element.getchildren():
            assert child.tag == 'tab'
            kw = loadxml.parseAttributes(child)
            label = kw.pop('label')
            tab = obj.newTab(label, **kw)
            for content in child.getchildren():
                loadxml.getConstructor(content.tag)(content, tab)
        return obj
Ejemplo n.º 4
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.

        Create tabs for <tab> child tags.
        '''
        kw = loadxml.parseAttributes(element)
        obj = cls(parent, **kw)
        for child in element.getchildren():
            assert child.tag == 'tab'
            kw = loadxml.parseAttributes(child)
            label = kw.pop('label')
            tab = obj.newTab(label, **kw)
            for content in child.getchildren():
                loadxml.getConstructor(content.tag)(content, tab)
        return obj
Ejemplo n.º 5
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.
        '''
        kw = loadxml.parseAttributes(element)
        text = xml.sax.saxutils.unescape(element.text)

        t = kw.get('type')
        if t == 'integer':
            value = int(text)
        elif t == 'time':
            if ':' in text:
                # (h:)m:s value
                value = map(int, text.split(':'))
                if len(value) == 2: m, s = value[0], value[1]
                else: h, m, s = value[0], value[1], value[2]
            else:
                # seconds value
                value = int(text)
                s = value % 60
                m = (value / 60) % 60
                h = value / 360
            value = datetime.time(h, m, s)
        else:
            value = text

        obj = cls(parent, value, **kw)

        #for child in element.getchildren():
        #    loadxml.getConstructor(element.tag)(child, obj)
        return obj
Ejemplo n.º 6
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.
        '''
        kw = loadxml.parseAttributes(element)
        text = xml.sax.saxutils.unescape(element.text)

        t = kw.get('type')
        if t == 'integer':
            value = int(text)
        elif t == 'time':
            if ':' in text:
                # (h:)m:s value
                value = map(int, text.split(':'))
                if len(value) == 2: m, s = value[0], value[1]
                else: h, m, s = value[0], value[1], value[2]
            else:
                # seconds value
                value = int(text)
                s = value % 60
                m = (value / 60) % 60
                h = value / 360
            value = datetime.time(h, m, s)
        else:
            value = text

        obj = cls(parent, value, **kw)

        #for child in element.getchildren():
        #    loadxml.getConstructor(element.tag)(child, obj)
        return obj
Ejemplo n.º 7
0
 def fromXML(cls, element, parent):
     """Create the object from the XML element and attach it to the parent.
     """
     kw = loadxml.parseAttributes(element)
     obj = cls(parent, **kw)
     for child in element.getchildren():
         loadxml.getConstructor(element.tag)(child, obj)
     return obj
Ejemplo n.º 8
0
 def fromXML(cls, element, parent):
     """Create the object from the XML element and attach it to the parent.
     """
     kw = loadxml.parseAttributes(element)
     obj = cls(parent, **kw)
     for child in element.getchildren():
         loadxml.getConstructor(element.tag)(child, obj)
     return obj
Ejemplo n.º 9
0
 def fromXML(cls, element, parent):
     '''Create the object from the XML element and attach it to the parent.
     '''
     kw = loadxml.parseAttributes(element)
     text = xml.sax.saxutils.unescape(element.text)
     obj = cls(parent, text, **kw)
     for child in element.getchildren():
         loadxml.getConstructor(element.tag)(child, obj)
     return obj
 def fromXML(cls, element, parent):
     '''Create the object from the XML element and attach it to the parent.
     '''
     kw = loadxml.parseAttributes(element)
     kw['text'] = xml.sax.saxutils.unescape(element.text)
     obj = cls(parent, **kw)
     for child in element.getchildren():
         loadxml.getConstructor(element.tag)(child, obj)
     return obj
Ejemplo n.º 11
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.

        If scrollable then put all children loaded into a container frame.
        '''
        kw = loadxml.parseAttributes(element)
        items = []
        for child in element.getchildren():
            text = xml.sax.saxutils.unescape(child.text)
            items.append((text, child.attrib['id']))
        return cls(parent, items, **kw)
Ejemplo n.º 12
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.

        If scrollable then put all children loaded into a container frame.
        '''
        kw = loadxml.parseAttributes(element)
        items = []
        for child in element.getchildren():
            text = xml.sax.saxutils.unescape(child.text)
            items.append((text, child.attrib['id']))
        return cls(parent, items, **kw)
Ejemplo n.º 13
0
 def fromXML(cls, element, parent):
     '''Create the object from the XML element and attach it to the parent.
     '''
     kw = loadxml.parseAttributes(element)
     children = element.getchildren()
     if children:
         text = ''.join(ElementTree.tostring(child) for child in children)
     else:
         text = ''
     text = element.text + text + element.tail
     obj = cls(parent, text, **kw)
     return obj
Ejemplo n.º 14
0
 def fromXML(cls, element, parent):
     '''Create the object from the XML element and attach it to the parent.
     '''
     kw = loadxml.parseAttributes(element)
     children = element.getchildren()
     if children:
         text = ''.join(ElementTree.tostring(child) for child in children)
     else:
         text = ''
     text = element.text + text + element.tail
     obj = cls(parent, text, **kw)
     return obj
Ejemplo n.º 15
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.

        If scrollable then put all children loaded into a container frame.
        '''
        kw = loadxml.parseAttributes(element)
        obj = cls(parent, **kw)
        for child in element.getchildren():
            if obj.scrollable:
                loadxml.getConstructor(child.tag)(child, obj.contents)
            else:
                loadxml.getConstructor(child.tag)(child, obj)
        return obj
Ejemplo n.º 16
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.

        If scrollable then put all children loaded into a container frame.
        '''
        kw = loadxml.parseAttributes(element)
        obj = cls(parent, **kw)
        for child in element.getchildren():
            if obj.scrollable:
                loadxml.getConstructor(child.tag)(child, obj.contents)
            else:
                loadxml.getConstructor(child.tag)(child, obj)
        return obj
Ejemplo n.º 17
0
 def fromXML(cls, element, parent):
     """Create the object from the XML element and attach it to the parent.
     """
     kw = loadxml.parseAttributes(element)
     if element.text:
         text = xml.sax.saxutils.unescape(element.text)
     else:
         text = None
     if 'image' in kw:
         kw['text'] = text
         obj = Button(parent, **kw)
     else:
         obj = TextButton(parent, text, **kw)
     for child in element.getchildren():
         loadxml.getConstructor(child.tag)(child, obj)
     return obj
Ejemplo n.º 18
0
 def fromXML(cls, element, parent):
     """Create the object from the XML element and attach it to the parent.
     """
     kw = loadxml.parseAttributes(element)
     if element.text:
         text = xml.sax.saxutils.unescape(element.text)
     else:
         text = None
     if 'image' in kw:
         kw['text'] = text
         obj = Button(parent, **kw)
     else:
         obj = TextButton(parent, text, **kw)
     for child in element.getchildren():
         loadxml.getConstructor(child.tag)(child, obj)
     return obj
Ejemplo n.º 19
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.

        If scrollable then put all children loaded into a container frame.
        '''
        kw = loadxml.parseAttributes(element)
        obj = cls(parent, **kw)
        for child in element.getchildren():
            if child.tag == 'row':
                Row.fromXML(child, obj.contents)
            elif child.tag == 'heading':
                obj.heading = Heading.fromXML(child, obj)
                obj.heading.layout.layout()
            else:
                raise ValueError, 'unexpected tag %r' % child.tag
        obj.contents.layout.layout()
        return obj
Ejemplo n.º 20
0
    def fromXML(cls, element, parent):
        '''Create the object from the XML element and attach it to the parent.

        If scrollable then put all children loaded into a container frame.
        '''
        kw = loadxml.parseAttributes(element)
        obj = cls(parent, **kw)
        for child in element.getchildren():
            if child.tag == 'row':
                Row.fromXML(child, obj.contents)
            elif child.tag == 'heading':
                obj.heading = Heading.fromXML(child, obj)
                obj.heading.layout.layout()
            else:
                raise ValueError, 'unexpected tag %r'%child.tag
        obj.contents.layout.layout()
        return obj