Python reportlab.lib.colors.gray() Examples

The following are 14 code examples of reportlab.lib.colors.gray(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module reportlab.lib.colors , or try the search function .
Example #1
Source File: reports.py    From testplan with Apache License 2.0 6 votes vote down vote up
def get_logs(self, source, depth, row_idx, lvl=logging.ERROR):
        """
        Get logs created by the `report.logger` object.
        Only select the logs with severity level equal to or higher than `lvl`.
        """
        font_size = const.FONT_SIZE_SMALL
        width = const.WRAP_LIMITS[font_size]
        logs = [log for log in source.logs if log["levelno"] >= lvl]

        return (
            RowData(
                start=row_idx,
                content=[
                    [wrap(log["message"], width=width), "", "", ""]
                    for log in logs
                ],
                style=RowStyle(
                    font=(const.FONT, font_size),
                    left_padding=const.INDENT * depth,
                    text_color=colors.gray,
                ),
            )
            if logs
            else None
        ) 
Example #2
Source File: reports.py    From testplan with Apache License 2.0 6 votes vote down vote up
def get_logs(self, source, depth, row_idx, lvl=logging.ERROR):
        """
        Get logs created by the `report.logger` object.
        Only select the logs with severity level equal to or higher than `lvl`.
        """
        font_size = const.FONT_SIZE_SMALL
        width = const.WRAP_LIMITS[font_size]
        logs = [log for log in source.logs if log["levelno"] >= lvl]

        return (
            RowData(
                start=row_idx,
                content=[
                    [wrap(log["message"], width=width), "", "", ""]
                    for log in logs
                ],
                style=RowStyle(
                    font=(const.FONT, font_size),
                    left_padding=const.INDENT * depth,
                    text_color=colors.gray,
                ),
            )
            if logs
            else None
        ) 
Example #3
Source File: doughnut.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def sample1():
    "Make up something from the individual Sectors"

    d = Drawing(400, 400)
    g = Group()

    s1 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=0, endangledegrees=120, radius1=100)
    s1.fillColor=colors.red
    s1.strokeColor=None
    d.add(s1)
    s2 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=120, endangledegrees=240, radius1=100)
    s2.fillColor=colors.green
    s2.strokeColor=None
    d.add(s2)
    s3 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=240, endangledegrees=260, radius1=100)
    s3.fillColor=colors.blue
    s3.strokeColor=None
    d.add(s3)
    s4 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=260, endangledegrees=360, radius1=100)
    s4.fillColor=colors.gray
    s4.strokeColor=None
    d.add(s4)

    return d 
Example #4
Source File: testshapes.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def getDrawing05():
    """Text strings with various anchors (alignments).

    Text alignment conforms to the anchors in the left column.
    """

    D = Drawing(400, 200)

    lineX = 250
    D.add(Line(lineX,10, lineX,190, strokeColor=colors.gray))

    y = 130
    for anchor in ('start', 'middle', 'end'):
        D.add(String(lineX, y, 'Hello World', textAnchor=anchor))
        D.add(String(50, y, anchor + ':'))
        y = y - 30

    return D 
Example #5
Source File: doughnut.py    From stdm with GNU General Public License v2.0 6 votes vote down vote up
def sample1():
    "Make up something from the individual Sectors"

    d = Drawing(400, 400)
    g = Group()

    s1 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=0, endangledegrees=120, radius1=100)
    s1.fillColor=colors.red
    s1.strokeColor=None
    d.add(s1)
    s2 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=120, endangledegrees=240, radius1=100)
    s2.fillColor=colors.green
    s2.strokeColor=None
    d.add(s2)
    s3 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=240, endangledegrees=260, radius1=100)
    s3.fillColor=colors.blue
    s3.strokeColor=None
    d.add(s3)
    s4 = Wedge(centerx=200, centery=200, radius=150, startangledegrees=260, endangledegrees=360, radius1=100)
    s4.fillColor=colors.gray
    s4.strokeColor=None
    d.add(s4)

    return d 
Example #6
Source File: testshapes.py    From stdm with GNU General Public License v2.0 6 votes vote down vote up
def getDrawing05():
    """Text strings with various anchors (alignments).

    Text alignment conforms to the anchors in the left column.
    """

    D = Drawing(400, 200)

    lineX = 250
    D.add(Line(lineX,10, lineX,190, strokeColor=colors.gray))

    y = 130
    for anchor in ('start', 'middle', 'end'):
        D.add(String(lineX, y, 'Hello World', textAnchor=anchor))
        D.add(String(50, y, anchor + ':'))
        y = y - 30

    return D 
Example #7
Source File: pdf.py    From correios with Apache License 2.0 6 votes vote down vote up
def draw_grid(self, canvas):
        canvas.setLineWidth(0.2)
        canvas.setStrokeColor(colors.gray)
        canvas.line(
            self.shipping_labels_margin[0],
            self.page_height / 2,
            self.shipping_labels_width + self.shipping_labels_margin[0],
            self.page_height / 2,
        )
        canvas.line(
            self.page_width / 2,
            self.shipping_labels_margin[1],
            self.page_width / 2,
            self.shipping_labels_height + self.shipping_labels_margin[1],
        )

    # noinspection PyUnusedLocal 
Example #8
Source File: table.py    From tia with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def apply_color(formatter, cmap=None, font_bw=1, stripe_rows=1, stripe_cols=0,
                    hdr_border_clazz=BorderTypeGrid, cell_border_clazz=BorderTypeOutline, border_weight=.7):
        """
        font_bw: bool, If True use black and white fonts. If False, then use the cmap
        """
        cmap = cmap or Style.Blue
        light = cmap.get('Light', white)
        medium = cmap.get('Medium', gray)
        dark = cmap.get('Dark', black)
        # the ranges
        header = formatter.all.iloc[:formatter.header.nrows]
        cells = formatter.all.iloc[formatter.header.nrows:]
        # color the header
        hdr_border_clazz and header.set_border_type(hdr_border_clazz, color=medium, weight=border_weight)
        header.set_textcolor(font_bw and white or light)
        header.set_background(dark)
        # color the cells
        cell_border_clazz and cells.set_border_type(cell_border_clazz, color=medium, weight=border_weight)
        stripe_rows and cells.set_row_backgrounds([light, white])
        stripe_cols and cells.set_col_backgrounds([white, light])
        not font_bw and cells.set_textcolor(dark) 
Example #9
Source File: templates.py    From PyInvoice with MIT License 5 votes vote down vote up
def _build_service_provider_and_client_info(self):
        if isinstance(self.service_provider_info, ServiceProviderInfo) and isinstance(self.client_info, ClientInfo):
            # Merge Table
            table_data = [
                [
                    Paragraph('Service Provider', self._defined_styles.get('Heading1')), '',
                    '',
                    Paragraph('Client', self._defined_styles.get('Heading1')), ''
                ]
            ]
            table_style = [
                ('SPAN', (0, 0), (1, 0)),
                ('SPAN', (3, 0), (4, 0)),
                ('LINEBELOW', (0, 0), (1, 0), 1, colors.gray),
                ('LINEBELOW', (3, 0), (4, 0), 1, colors.gray),
                ('LEFTPADDING', (0, 0), (-1, -1), 0),
            ]
            client_info_data = self._client_info_data()
            service_provider_data = self._service_provider_data()
            diff = abs(len(client_info_data) - len(service_provider_data))
            if diff > 0:
                if len(client_info_data) < len(service_provider_data):
                    client_info_data.extend([["", ""]]*diff)
                else:
                    service_provider_data.extend([["", ""]*diff])
            for d in zip(service_provider_data, client_info_data):
                d[0].append('')
                d[0].extend(d[1])
                table_data.append(d[0])
            self._story.append(
                Table(table_data, style=table_style)
            )
        else:
            self._build_service_provider_info()
            self._build_client_info() 
Example #10
Source File: signsandsymbols.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def draw(self):
        # general widget bits
        s = float(self.size)  # abbreviate as we will use this a lot
        g = NotAllowed.draw(self)

        # no-smoking-sign specific bits
        newx = self.x+(s/2)-(s/3.5)
        newy = self.y+(s/2)-(s/32)
        cigarrette1 = shapes.Rect(x = newx, y = newy, width = (s/2), height =(s/16),
                fillColor = colors.ghostwhite, strokeColor = colors.gray, strokeWidth=0)
        newx=newx+(s/2)+(s/64)
        g.insert(-1,cigarrette1)

        cigarrette2 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16),
                fillColor = colors.orangered, strokeColor = None, strokeWidth=0)
        newx= newx+(s/35)
        g.insert(-1,cigarrette2)

        cigarrette3 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16),
                fillColor = colors.orangered, strokeColor = None, strokeWidth=0)
        newx= newx+(s/35)
        g.insert(-1,cigarrette3)

        cigarrette4 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16),
                fillColor = colors.orangered, strokeColor = None, strokeWidth=0)
        newx= newx+(s/35)
        g.insert(-1,cigarrette4)

        return g 
Example #11
Source File: flowables.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def drawOn(self, canvas, x, y, _sW=0):
        "Tell it to draw itself on the canvas.  Do not override"
        x = self._hAlignAdjust(x,_sW)
        canvas.saveState()
        canvas.translate(x, y)
        self._drawOn(canvas)
        if hasattr(self, '_showBoundary') and self._showBoundary:
            #diagnostic tool support
            canvas.setStrokeColor(gray)
            canvas.rect(0,0,self.width, self.height)
        canvas.restoreState() 
Example #12
Source File: templates.py    From HH---POS-Accounting-and-ERP-Software with MIT License 5 votes vote down vote up
def _build_service_provider_and_client_info(self):
        if isinstance(self.service_provider_info, ServiceProviderInfo) and isinstance(self.client_info, ClientInfo):
            # Merge Table
            table_data = [
                [
                    Paragraph('Service Provider', self._defined_styles.get('Heading1')), '',
                    '',
                    Paragraph('Client', self._defined_styles.get('Heading1')), ''
                ]
            ]
            table_style = [
                ('SPAN', (0, 0), (1, 0)),
                ('SPAN', (3, 0), (4, 0)),
                ('LINEBELOW', (0, 0), (1, 0), 1, colors.gray),
                ('LINEBELOW', (3, 0), (4, 0), 1, colors.gray),
                ('LEFTPADDING', (0, 0), (-1, -1), 0),
            ]
            client_info_data = self._client_info_data()
            service_provider_data = self._service_provider_data()
            diff = abs(len(client_info_data) - len(service_provider_data))
            if diff > 0:
                if len(client_info_data) < len(service_provider_data):
                    client_info_data.extend([["", ""]]*diff)
                else:
                    service_provider_data.extend([["", ""]*diff])
            for d in zip(service_provider_data, client_info_data):
                d[0].append('')
                d[0].extend(d[1])
                table_data.append(d[0])
            self._story.append(
                Table(table_data, style=table_style)
            )
        else:
            self._build_service_provider_info()
            self._build_client_info() 
Example #13
Source File: signsandsymbols.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def draw(self):
        # general widget bits
        s = float(self.size)  # abbreviate as we will use this a lot
        g = NotAllowed.draw(self)

        # no-smoking-sign specific bits
        newx = self.x+(s/2)-(s/3.5)
        newy = self.y+(s/2)-(s/32)
        cigarrette1 = shapes.Rect(x = newx, y = newy, width = (s/2), height =(s/16),
                fillColor = colors.ghostwhite, strokeColor = colors.gray, strokeWidth=0)
        newx=newx+(s/2)+(s/64)
        g.insert(-1,cigarrette1)

        cigarrette2 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16),
                fillColor = colors.orangered, strokeColor = None, strokeWidth=0)
        newx= newx+(s/35)
        g.insert(-1,cigarrette2)

        cigarrette3 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16),
                fillColor = colors.orangered, strokeColor = None, strokeWidth=0)
        newx= newx+(s/35)
        g.insert(-1,cigarrette3)

        cigarrette4 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16),
                fillColor = colors.orangered, strokeColor = None, strokeWidth=0)
        newx= newx+(s/35)
        g.insert(-1,cigarrette4)

        return g 
Example #14
Source File: flowables.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def drawOn(self, canvas, x, y, _sW=0):
        "Tell it to draw itself on the canvas.  Do not override"
        x = self._hAlignAdjust(x,_sW)
        canvas.saveState()
        canvas.translate(x, y)
        self._drawOn(canvas)
        if hasattr(self, '_showBoundary') and self._showBoundary:
            #diagnostic tool support
            canvas.setStrokeColor(gray)
            canvas.rect(0,0,self.width, self.height)
        canvas.restoreState()