Python reportlab.lib.colors.white() Examples

The following are 30 code examples of reportlab.lib.colors.white(). 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: report.py    From flask-restful-example with MIT License 10 votes vote down vote up
def table_model():
    """
    添加表格
    :return:
    """
    template_path = current_app.config.get("REPORT_TEMPLATES")
    image_path = os.path.join(template_path, 'test.jpg')
    new_img = Image(image_path, width=300, height=300)
    base = [
        [new_img, ""],
        ["大类", "小类"],
        ["WebFramework", "django"],
        ["", "flask"],
        ["", "web.py"],
        ["", "tornado"],
        ["Office", "xlsxwriter"],
        ["", "openpyxl"],
        ["", "xlrd"],
        ["", "xlwt"],
        ["", "python-docx"],
        ["", "docxtpl"],
    ]

    style = [
        # 设置字体
        ('FONTNAME', (0, 0), (-1, -1), 'SimSun'),

        # 合并单元格 (列,行)
        ('SPAN', (0, 0), (1, 0)),
        ('SPAN', (0, 2), (0, 5)),
        ('SPAN', (0, 6), (0, 11)),

        # 单元格背景
        ('BACKGROUND', (0, 1), (1, 1), HexColor('#548DD4')),

        # 字体颜色
        ('TEXTCOLOR', (0, 1), (1, 1), colors.white),
        # 对齐设置
        ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
        ('ALIGN', (0, 0), (-1, -1), 'CENTER'),

        # 单元格框线
        ('GRID', (0, 0), (-1, -1), 0.5, colors.grey),
        ('BOX', (0, 0), (-1, -1), 0.5, colors.black),

    ]

    component_table = Table(base, style=style)
    return component_table 
Example #2
Source File: linecharts.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
def demo(self):
        """Shows basic use of a line chart."""

        drawing = Drawing(200, 100)

        data = [
                (13, 5, 20, 22, 37, 45, 19, 4),
                (14, 10, 21, 28, 38, 46, 25, 5)
                ]

        lc = SampleHorizontalLineChart()

        lc.x = 20
        lc.y = 10
        lc.height = 85
        lc.width = 170
        lc.data = data
        lc.strokeColor = colors.white
        lc.fillColor = colors.HexColor(0xCCCCCC)

        drawing.add(lc)

        return drawing 
Example #3
Source File: test_basic.py    From svglib with GNU Lesser General Public License v3.0 6 votes vote down vote up
def test_filling(self):
        converter = svglib.Svg2RlgShapeConverter(None)
        node = svglib.NodeTracker(etree.XML(
            '<polyline fill="none" stroke="#000000" '
            'points="10,50,35,150,60,50,85,150,110,50,135,150" />'
        ))
        polyline = converter.convertPolyline(node)
        assert isinstance(polyline, PolyLine)

        # svglib simulates polyline filling by a fake polygon.
        node = svglib.NodeTracker(etree.XML(
            '<polyline fill="#fff" stroke="#000000" '
            'points="10,50,35,150,60,50,85,150,110,50,135,150" />'
        ))
        group = converter.convertPolyline(node)
        assert isinstance(group.contents[0], Polygon)
        assert group.contents[0].fillColor == colors.white
        assert isinstance(group.contents[1], PolyLine) 
Example #4
Source File: linecharts.py    From stdm with GNU General Public License v2.0 6 votes vote down vote up
def demo(self):
        """Shows basic use of a line chart."""

        drawing = Drawing(200, 100)

        data = [
                (13, 5, 20, 22, 37, 45, 19, 4),
                (14, 10, 21, 28, 38, 46, 25, 5)
                ]

        lc = SampleHorizontalLineChart()

        lc.x = 20
        lc.y = 10
        lc.height = 85
        lc.width = 170
        lc.data = data
        lc.strokeColor = colors.white
        lc.fillColor = colors.HexColor(0xCCCCCC)

        drawing.add(lc)

        return drawing 
Example #5
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 #6
Source File: widgetbase.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def test():
    from reportlab.graphics.charts.piecharts import WedgeProperties
    wedges = TypedPropertyCollection(WedgeProperties)
    wedges.fillColor = colors.red
    wedges.setVector(fillColor=(colors.blue,colors.green,colors.white))
    print len(_ItemWrapper)

    d = shapes.Drawing(400, 200)
    tc = TwoCircles()
    d.add(tc)
    import renderPDF
    renderPDF.drawToFile(d, 'sample_widget.pdf', 'A Sample Widget')
    print 'saved sample_widget.pdf'

    d = shapes.Drawing(400, 200)
    f = Face()
    f.skinColor = colors.yellow
    f.mood = "sad"
    d.add(f, name='theFace')
    print 'drawing 1 properties:'
    d.dumpProperties()
    renderPDF.drawToFile(d, 'face.pdf', 'A Sample Widget')
    print 'saved face.pdf'

    d2 = d.expandUserNodes()
    renderPDF.drawToFile(d2, 'face_copy.pdf', 'An expanded drawing')
    print 'saved face_copy.pdf'
    print 'drawing 2 properties:'
    d2.dumpProperties() 
Example #7
Source File: corp.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test():
    """This function produces a pdf with examples. """

    #white on blue
    rl = RL_CorpLogo()
    rl.width = 129
    rl.height = 86
    D = Drawing(rl.width,rl.height)
    D.add(rl)
    D.__dict__['verbose'] = 1
    D.save(fnRoot='corplogo_whiteonblue',formats=['pdf','eps','jpg','gif'])


    #blue on white
    rl = RL_CorpLogoReversed()
    rl.width = 129
    rl.height = 86
    D = Drawing(rl.width,rl.height)
    D.add(rl)
    D.__dict__['verbose'] = 1
    D.save(fnRoot='corplogo_blueonwhite',formats=['pdf','eps','jpg','gif'])

    #gray on white
    rl = RL_CorpLogoReversed()
    rl.fillColor = Color(0.2, 0.2, 0.2)
    rl.width = 129
    rl.height = 86
    D = Drawing(rl.width,rl.height)
    D.add(rl)
    D.__dict__['verbose'] = 1
    D.save(fnRoot='corplogo_grayonwhite',formats=['pdf','eps','jpg','gif'])


    rl = RL_BusinessCard()
    rl.x=25
    rl.y=25
    rl.border=1
    D = Drawing(rl.width+50,rl.height+50)
    D.add(rl)
    D.__dict__['verbose'] = 1
    D.save(fnRoot='RL_BusinessCard',formats=['pdf']) 
Example #8
Source File: corp.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        self.fillColor = ReportLabBlue
        self.strokeColor = black
        self.altStrokeColor = white
        self.x = 0
        self.y = 0
        self.height = self._h
        self.width = self._w
        self.borderWidth = self.width/6.15
        self.bleed=0.2*cm
        self.cropMarks=1
        self.border=0
        #Over-ride these with your own info
        self.name="Joe Cool"
        self.position="Freelance Demonstrator"
        self.telephone="020 8545 7271"
        self.mobile="-"
        self.fax="020 8544 1311"
        self.email="info@reportlab.com"
        self.web="www.reportlab.com"
        self.rh_blurb_top = ["London office:",
                     "ReportLab Europe Ltd",
                     "Media House",
                     "3 Palmerston Road",
                     "Wimbledon",
                     "London SW19 1PG",
                     "United Kingdom"] 
Example #9
Source File: test_basic.py    From svglib with GNU Lesser General Public License v3.0 5 votes vote down vote up
def test_stroke(self):
        converter = svglib.Svg2RlgShapeConverter(None)
        node = etree.XML('<path d="m0,6.5h27m0,5H0" stroke="#FFF" stroke-opacity="0.5"/>')
        path = Path()
        converter.applyStyleOnShape(path, node)
        assert path.strokeColor == colors.white
        assert path.strokeOpacity == 0.5
        assert path.strokeWidth == 1 
Example #10
Source File: linecharts.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def sample1a():
    drawing = Drawing(400, 200)

    data = [
            (13, 5, 20, 22, 37, 45, 19, 4),
            (5, 20, 46, 38, 23, 21, 6, 14)
            ]

    lc = SampleHorizontalLineChart()

    lc.x = 50
    lc.y = 50
    lc.height = 125
    lc.width = 300
    lc.data = data
    lc.joinedLines = 1
    lc.strokeColor = colors.white
    lc.fillColor = colors.HexColor(0xCCCCCC)
    lc.lines.symbol = makeMarker('FilledDiamond')
    lc.lineLabelFormat = '%2.0f'

    catNames = 'Jan Feb Mar Apr May Jun Jul Aug'.split(' ')
    lc.categoryAxis.categoryNames = catNames
    lc.categoryAxis.labels.boxAnchor = 'n'

    lc.valueAxis.valueMin = 0
    lc.valueAxis.valueMax = 60
    lc.valueAxis.valueStep = 15

    drawing.add(lc)

    return drawing 
Example #11
Source File: markers.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def makeEmptyCircle(x, y, size, color):
    "Make a hollow circle marker."

    d = size/2.0
    circle = Circle(x, y, d)
    circle.strokeColor = color
    circle.fillColor = colors.white

    return circle 
Example #12
Source File: corp.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        self.fillColor = ReportLabBlue
        self.strokeColor = white
        self.x = 0
        self.y = 0
        self.height = self._h
        self.width = self._w 
Example #13
Source File: corp.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        RL_CorpLogo.__init__(self)
        self.background = white
        self.fillColor = ReportLabBlue 
Example #14
Source File: corp.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        self.fillColor = white
        self.strokeColor = None
        self.strokeWidth = 0.1
        self.background = ReportLabBlue
        self.border = None
        self.borderWidth = 1
        self.shadow = 0.5
        self.height = 86
        self.width = 130
        self.x = self.y = self.angle = self.skewY = self._dx = 0
        self.skewX = 10
        self._dy = 35.5
        self.showPage = 1 
Example #15
Source File: corp.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self.fillColor = ReportLabBlue
        self.strokeColor = white
        self.x = 0
        self.y = 0
        self.height = self._h
        self.width = self._w 
Example #16
Source File: signsandsymbols.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        self.x = 0
        self.y = 0
        self.size = 100
        self.fillColor = colors.white
        self.crossColor = colors.red
        self.strokeColor = colors.black
        self.crosswidth = 10 
Example #17
Source File: signsandsymbols.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        self.x = 0
        self.y = 0
        self.size = 100
        self.tickColor = colors.red
        self.strokeColor = colors.black
        self.fillColor = colors.white
        self.tickwidth = 10 
Example #18
Source File: flags.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self,**kw):
        _Symbol.__init__(self)
        self.kind = None
        self.size = 100
        self.fillColor = colors.white
        self.border=1
        self.setProperties(kw) 
Example #19
Source File: grids.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        self.x = 0
        self.y = 0
        self.width = 100
        self.height = 100
        self.orientation = 'vertical'
        self.useLines = 0
        self.useRects = 1
        self.delta = 20
        self.delta0 = 0
        self.deltaSteps = []
        self.fillColor = colors.white
        self.stripeColors = [colors.red, colors.green, colors.blue]
        self.strokeColor = colors.black
        self.strokeWidth = 2 
Example #20
Source File: textobject.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def setStrokeGray(self, gray, alpha=None):
        """Sets the gray level; 0.0=black, 1.0=white"""
        self._strokeColorObj = (gray, gray, gray)
        self._code.append('%s G' % fp_str(gray))
        if alpha is not None:
            self.setFillAlpha(alpha) 
Example #21
Source File: textobject.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def setFillGray(self, gray, alpha=None):
        """Sets the gray level; 0.0=black, 1.0=white"""
        self._fillColorObj = (gray, gray, gray)
        self._code.append('%s g' % fp_str(gray))
        if alpha is not None:
            self.setFillAlpha(alpha) 
Example #22
Source File: corp.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self.fillColor = ReportLabBlue
        self.strokeColor = black
        self.altStrokeColor = white
        self.x = 0
        self.y = 0
        self.height = self._h
        self.width = self._w
        self.borderWidth = self.width/6.15
        self.bleed=0.2*cm
        self.cropMarks=1
        self.border=0
        #Over-ride these with your own info
        self.name="Joe Cool"
        self.position="Freelance Demonstrator"
        self.telephone="020 8545 7271"
        self.mobile="-"
        self.fax="020 8544 1311"
        self.email="info@reportlab.com"
        self.web="www.reportlab.com"
        self.rh_blurb_top = ["London office:",
                     "ReportLab Europe Ltd",
                     "Media House",
                     "3 Palmerston Road",
                     "Wimbledon",
                     "London SW19 1PG",
                     "United Kingdom"] 
Example #23
Source File: corp.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        RL_CorpLogo.__init__(self)
        self.background = white
        self.fillColor = ReportLabBlue 
Example #24
Source File: corp.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self.fillColor = white
        self.strokeColor = None
        self.strokeWidth = 0.1
        self.background = ReportLabBlue
        self.border = None
        self.borderWidth = 1
        self.shadow = 0.5
        self.height = 86
        self.width = 130
        self.x = self.y = self.angle = self.skewY = self._dx = 0
        self.skewX = 10
        self._dy = 35.5
        self.showPage = 1 
Example #25
Source File: textobject.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def setStrokeGray(self, gray, alpha=None):
        """Sets the gray level; 0.0=black, 1.0=white"""
        self._strokeColorObj = (gray, gray, gray)
        self._code.append('%s G' % fp_str(gray))
        if alpha is not None:
            self.setFillAlpha(alpha) 
Example #26
Source File: textobject.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def setFillGray(self, gray, alpha=None):
        """Sets the gray level; 0.0=black, 1.0=white"""
        self._fillColorObj = (gray, gray, gray)
        self._code.append('%s g' % fp_str(gray))
        if alpha is not None:
            self.setFillAlpha(alpha) 
Example #27
Source File: corp.py    From stdm with GNU General Public License v2.0 5 votes vote down vote up
def test():
    """This function produces a pdf with examples. """

    #white on blue
    rl = RL_CorpLogo()
    rl.width = 129
    rl.height = 86
    D = Drawing(rl.width,rl.height)
    D.add(rl)
    D.__dict__['verbose'] = 1
    D.save(fnRoot='corplogo_whiteonblue',formats=['pdf','eps','jpg','gif'])


    #blue on white
    rl = RL_CorpLogoReversed()
    rl.width = 129
    rl.height = 86
    D = Drawing(rl.width,rl.height)
    D.add(rl)
    D.__dict__['verbose'] = 1
    D.save(fnRoot='corplogo_blueonwhite',formats=['pdf','eps','jpg','gif'])

    #gray on white
    rl = RL_CorpLogoReversed()
    rl.fillColor = Color(0.2, 0.2, 0.2)
    rl.width = 129
    rl.height = 86
    D = Drawing(rl.width,rl.height)
    D.add(rl)
    D.__dict__['verbose'] = 1
    D.save(fnRoot='corplogo_grayonwhite',formats=['pdf','eps','jpg','gif'])


    rl = RL_BusinessCard()
    rl.x=25
    rl.y=25
    rl.border=1
    D = Drawing(rl.width+50,rl.height+50)
    D.add(rl)
    D.__dict__['verbose'] = 1
    D.save(fnRoot='RL_BusinessCard',formats=['pdf']) 
Example #28
Source File: grids.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self.x = 0
        self.y = 0
        self.width = 100
        self.height = 100
        self.orientation = 'vertical'
        self.useLines = 0
        self.useRects = 1
        self.delta = 20
        self.delta0 = 0
        self.deltaSteps = []
        self.fillColor = colors.white
        self.stripeColors = [colors.red, colors.green, colors.blue]
        self.strokeColor = colors.black
        self.strokeWidth = 2 
Example #29
Source File: flags.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,**kw):
        _Symbol.__init__(self)
        self.kind = None
        self.size = 100
        self.fillColor = colors.white
        self.border=1
        self.setProperties(kw) 
Example #30
Source File: signsandsymbols.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self.x = 0
        self.y = 0
        self.size = 100
        self.tickColor = colors.red
        self.strokeColor = colors.black
        self.fillColor = colors.white
        self.tickwidth = 10