Beispiel #1
0
class Table(element.Element):
    name = 'table'
    h_slider = None
    v_slider = None

    def __init__(self, parent, size=None, is_exclusive=False,
                 color=(0, 0, 0, 1), bgcolor=(1, 1, 1, 1),
                 alt_bgcolor=(.9, .9, .9, 1), active_bgcolor=(1, .8, .8, 1),
                 x=0, y=0, z=0, width='100%', height=None, **kw):
        font_size = parent.getStyle().font_size
        size = util.parse_value(size, None)
        if size is not None:
            height = (size + 1) * font_size

        self.is_exclusive = is_exclusive

        super().__init__(parent, x, y, z, width, height,
                         bgcolor=bgcolor, **kw)

        # rows go in under the heading
        # self.contents = TableContainer(self)
        self.contents = ContainerFrame(self)
        self.contents.layout = layouts.Layout(self.contents)
        self.contents.checkForScrollbars()

        # specific attributes for rows
        self.color = util.parse_color(color)
        self.base_bgcolor = self.bgcolor
        self.alt_bgcolor = util.parse_color(alt_bgcolor)
        self.active_bgcolor = util.parse_color(active_bgcolor)

    def get_inner_rect(self):
        p = self.padding
        font_size = self.getStyle().font_size
        return util.Rect(p, p, self.width - p * 2,
                         self.height - p * 2 - font_size)

    inner_rect = property(get_inner_rect)

    def layoutDimensionsChanged(self, layout):
        pass

    @classmethod
    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
Beispiel #2
0
    def __init__(self,
                 parent,
                 size=None,
                 is_exclusive=False,
                 color=(0, 0, 0, 1),
                 bgcolor=(1, 1, 1, 1),
                 alt_bgcolor=(.9, .9, .9, 1),
                 active_bgcolor=(1, .8, .8, 1),
                 x=0,
                 y=0,
                 z=0,
                 width='100%',
                 height=None,
                 **kw):
        font_size = parent.getStyle().font_size
        size = util.parse_value(size, None)
        if size is not None:
            height = (size + 1) * font_size

        self.is_exclusive = is_exclusive

        super().__init__(parent, x, y, z, width, height, bgcolor=bgcolor, **kw)

        # rows go in under the heading
        # self.contents = TableContainer(self)
        self.contents = ContainerFrame(self)
        self.contents.layout = layouts.Layout(self.contents)
        self.contents.checkForScrollbars()

        # specific attributes for rows
        self.color = util.parse_color(color)
        self.base_bgcolor = self.bgcolor
        self.alt_bgcolor = util.parse_color(alt_bgcolor)
        self.active_bgcolor = util.parse_color(active_bgcolor)
Beispiel #3
0
    def __init__(self, parent, size=None, is_exclusive=False,
            color=(0, 0, 0, 1), bgcolor=(1, 1, 1, 1),
            alt_bgcolor=(.9, .9, .9, 1), active_bgcolor=(1, .8, .8, 1),
            x=0, y=0, z=0, width='100%', height=None, **kw):
        font_size = parent.getStyle().font_size
        size = util.parse_value(size, None)
        if size is not None:
            height = (size + 1) * font_size

        self.is_exclusive = is_exclusive

        super(Table, self).__init__(parent, x, y, z, width, height,
            bgcolor=bgcolor, **kw)

        # rows go in under the heading
        #self.contents = TableContainer(self)
        self.contents = ContainerFrame(self)
        self.contents.layout = layouts.Layout(self.contents)
        self.contents.checkForScrollbars()

        # specific attributes for rows
        self.color = util.parse_color(color)
        self.base_bgcolor = self.bgcolor
        self.alt_bgcolor = util.parse_color(alt_bgcolor)
        self.active_bgcolor = util.parse_color(active_bgcolor)
Beispiel #4
0
class Table(element.Element):
    name = 'table'
    h_slider = None
    v_slider = None

    def __init__(self,
                 parent,
                 size=None,
                 is_exclusive=False,
                 color=(0, 0, 0, 1),
                 bgcolor=(1, 1, 1, 1),
                 alt_bgcolor=(.9, .9, .9, 1),
                 active_bgcolor=(1, .8, .8, 1),
                 x=0,
                 y=0,
                 z=0,
                 width='100%',
                 height=None,
                 **kw):
        font_size = parent.getStyle().font_size
        size = util.parse_value(size, None)
        if size is not None:
            height = (size + 1) * font_size

        self.is_exclusive = is_exclusive

        super(Table, self).__init__(parent,
                                    x,
                                    y,
                                    z,
                                    width,
                                    height,
                                    bgcolor=bgcolor,
                                    **kw)

        # rows go in under the heading
        #self.contents = TableContainer(self)
        self.contents = ContainerFrame(self)
        self.contents.layout = layouts.Layout(self.contents)
        self.contents.checkForScrollbars()

        # specific attributes for rows
        self.color = util.parse_color(color)
        self.base_bgcolor = self.bgcolor
        self.alt_bgcolor = util.parse_color(alt_bgcolor)
        self.active_bgcolor = util.parse_color(active_bgcolor)

    def get_inner_rect(self):
        p = self.padding
        font_size = self.getStyle().font_size
        return util.Rect(p, p, self.width - p * 2,
                         self.height - p * 2 - font_size)

    inner_rect = property(get_inner_rect)

    def layoutDimensionsChanged(self, layout):
        pass

    @classmethod
    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