当前位置: 首页>>代码示例>>Python>>正文


Python colors.HexColor方法代码示例

本文整理汇总了Python中reportlab.lib.colors.HexColor方法的典型用法代码示例。如果您正苦于以下问题:Python colors.HexColor方法的具体用法?Python colors.HexColor怎么用?Python colors.HexColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.lib.colors的用法示例。


在下文中一共展示了colors.HexColor方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: demo

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
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 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:linecharts.py

示例2: test_0

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
def test_0(self):
        "Test color attribute conversion."

        mapping = (
            ("red", colors.red),
            ("#ff0000", colors.red),
            ("#ff000055", colors.Color(1, 0, 0, 1/3.0)),
            ("#f00", colors.red),
            ("#f00f", colors.red),
            ("rgb(100%,50%,10%)", colors.Color(1, 1.0/255 * 128, 1.0/255 * 26, 1)),
            ("rgb(255, 0, 0)", colors.red),
            ("rgba(255, 255, 128, .5)", colors.Color(1, 1, 1.0/255 * 128, .5)),
            ("fuchsia", colors.Color(1, 0, 1, 1)),
            ("slategrey", colors.HexColor(0x708090)),
            ("transparent", colors.Color(0, 0, 0, 0)),
            ("whatever", None),
        )
        ac = svglib.Svg2RlgAttributeConverter()
        failed = _testit(ac.convertColor, mapping)
        assert len(failed) == 0 
开发者ID:deeplook,项目名称:svglib,代码行数:22,代码来源:test_basic.py

示例3: table_model

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
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 
开发者ID:qzq1111,项目名称:flask-restful-example,代码行数:51,代码来源:report.py

示例4: sample1a

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
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 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:34,代码来源:linecharts.py

示例5: __init__

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
def __init__(self):
        super(CalculoImpostoRetrato, self).__init__()
        self.elements = []
        self.inclui_descritivo(nome='clc', titulo=u'CÁLCULO DO IMPOSTO', top=0*cm, left=0*cm, width=19.4*cm)

        # 1ª linha
        lbl, fld = self.inclui_campo_numerico(nome='clc_bip', titulo=u'BASE DE CÁLCULO DO ICMS', conteudo=u'NFe.infNFe.total.ICMSTot.vBC.formato_danfe', top=0.42*cm, left=0*cm, width=3.88*cm)
        lbl, fld = self.inclui_campo_numerico(nome='clc_vip', titulo=u'VALOR DO ICMS', conteudo=u'NFe.infNFe.total.ICMSTot.vICMS.formato_danfe', top=0.42*cm, left=3.88*cm, width=3.88*cm)
        lbl, fld = self.inclui_campo_numerico(nome='clc_bis', titulo=u'BASE DE CÁLCULO DO ICMS ST', conteudo=u'NFe.infNFe.total.ICMSTot.vBCST.formato_danfe', top=0.42*cm, left=7.76*cm, width=3.88*cm)
        lbl, fld = self.inclui_campo_numerico(nome='clc_vis', titulo=u'VALOR DO ICMS ST', conteudo=u'NFe.infNFe.total.ICMSTot.vST.formato_danfe', top=0.42*cm, left=11.64*cm, width=3.88*cm)
        lbl, fld = self.inclui_campo_numerico(nome='clc_vpn', titulo=u'VALOR TOTAL DOS PRODUTOS', conteudo=u'NFe.infNFe.total.ICMSTot.vProd.formato_danfe', top=0.42*cm, left=15.52*cm, width=3.88*cm, margem_direita=True)
        #fld.style = DADO_CAMPO_NUMERICO_NEGRITO

        # 2ª linha
        lbl, fld = self.inclui_campo_numerico(nome='clc_vfrete', titulo=u'VALOR DO FRETE', conteudo=u'NFe.infNFe.total.ICMSTot.vFrete.formato_danfe', top=1.12*cm, left=0*cm, width=3.104*cm)
        lbl, fld = self.inclui_campo_numerico(nome='clc_vseguro', titulo=u'VALOR DO SEGURO', conteudo=u'NFe.infNFe.total.ICMSTot.vSeg.formato_danfe', top=1.12*cm, left=3.104*cm, width=3.104*cm)
        lbl, fld = self.inclui_campo_numerico(nome='clc_vdesconto', titulo=u'DESCONTO', conteudo=u'NFe.infNFe.total.ICMSTot.vDesc.formato_danfe', top=1.12*cm, left=6.208*cm, width=3.104*cm)
        lbl, fld = self.inclui_campo_numerico(nome='clc_voutras', titulo=u'OUTRAS DESPESAS ACESSÓRIAS', conteudo=u'NFe.infNFe.total.ICMSTot.vOutro.formato_danfe', top=1.12*cm, left=9.312*cm, width=3.104*cm)
        lbl, fld = self.inclui_campo_numerico(nome='clc_vipi', titulo=u'VALOR TOTAL DO IPI', conteudo=u'NFe.infNFe.total.ICMSTot.vIPI.formato_danfe', top=1.12*cm, left=12.416*cm, width=3.104*cm)

        # Fundo destacado do total da NF
        self.elements.append(Rect(top=1.12*cm, left=15.52*cm, height=0.7*cm, width=3.88*cm, stroke=False, stroke_width=0, fill=True, fill_color=HexColor(0xd0d0d0)))
        lbl, fld = self.inclui_campo_numerico(nome='clc_vnf', titulo=u'VALOR TOTAL DA NOTA', conteudo=u'NFe.infNFe.total.ICMSTot.vNF.formato_danfe', top=1.12*cm, left=15.52*cm, width=3.88*cm, margem_direita=True)
        lbl.style = DESCRITIVO_CAMPO_NEGRITO
        fld.style = DADO_CAMPO_NUMERICO_NEGRITO

        self.height = 1.82*cm 
开发者ID:thiagopena,项目名称:PySIGNFe,代码行数:29,代码来源:danferetrato.py

示例6: __init__

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
def __init__(self):
        super(CalculoImpostoPaisagem, self).__init__()
        self.elements = []
        self.inclui_descritivo(nome='clc', titulo=u'CÁLCULO DO IMPOSTO', top=0*cm, left=2.6*cm, width=26.8*cm, height=0.4*cm)

        # 1ª linha
        lbl, fld = self.inclui_campo_numerico(nome='clc_bip', titulo=u'BASE DE CÁLCULO DO ICMS', conteudo=u'NFe.infNFe.total.ICMSTot.vBC.formato_danfe', top=0.4*cm, left=2.6*cm, width=5.4*cm, height=0.6*cm)
        fld.padding_top = 0.18*cm
        lbl, fld = self.inclui_campo_numerico(nome='clc_vip', titulo=u'VALOR DO ICMS', conteudo=u'NFe.infNFe.total.ICMSTot.vICMS.formato_danfe', top=0.4*cm, left=8*cm, width=5.4*cm, height=0.6*cm)
        fld.padding_top = 0.18*cm
        lbl, fld = self.inclui_campo_numerico(nome='clc_bis', titulo=u'BASE DE CÁLCULO DO ICMS ST', conteudo=u'NFe.infNFe.total.ICMSTot.vBCST.formato_danfe', top=0.4*cm, left=13.4*cm, width=5.4*cm, height=0.6*cm)
        fld.padding_top = 0.18*cm
        lbl, fld = self.inclui_campo_numerico(nome='clc_vis', titulo=u'VALOR DO ICMS ST', conteudo=u'NFe.infNFe.total.ICMSTot.vST.formato_danfe', top=0.4*cm, left=18.8*cm, width=5.4*cm, height=0.6*cm)
        fld.padding_top = 0.18*cm
        lbl, fld = self.inclui_campo_numerico(nome='clc_vpn', titulo=u'VALOR TOTAL DOS PRODUTOS', conteudo=u'NFe.infNFe.total.ICMSTot.vProd.formato_danfe', top=0.4*cm, left=24.2*cm, width=5.2*cm, height=0.6*cm, margem_direita=True)
        fld.padding_top = 0.18*cm
        #fld.style = DADO_CAMPO_NUMERICO_NEGRITO

        # 2ª linha
        lbl, fld = self.inclui_campo_numerico(nome='clc_vfrete', titulo=u'VALOR DO FRETE', conteudo=u'NFe.infNFe.total.ICMSTot.vFrete.formato_danfe', top=1*cm, left=2.6*cm, width=4.4*cm, height=0.6*cm)
        fld.padding_top = 0.18*cm
        lbl, fld = self.inclui_campo_numerico(nome='clc_vseguro', titulo=u'VALOR DO SEGURO', conteudo=u'NFe.infNFe.total.ICMSTot.vSeg.formato_danfe', top=1*cm, left=7*cm, width=4.4*cm, height=0.6*cm)
        fld.padding_top = 0.18*cm
        lbl, fld = self.inclui_campo_numerico(nome='clc_vdesconto', titulo=u'DESCONTO', conteudo=u'NFe.infNFe.total.ICMSTot.vDesc.formato_danfe', top=1*cm, left=11.4*cm, width=4.4*cm, height=0.6*cm)
        fld.padding_top = 0.18*cm
        lbl, fld = self.inclui_campo_numerico(nome='clc_voutras', titulo=u'OUTRAS DESPESAS ACESSÓRIAS', conteudo=u'NFe.infNFe.total.ICMSTot.vOutro.formato_danfe', top=1*cm, left=15.8*cm, width=4.4*cm, height=0.6*cm)
        fld.padding_top = 0.18*cm
        lbl, fld = self.inclui_campo_numerico(nome='clc_vipi', titulo=u'VALOR TOTAL DO IPI', conteudo=u'NFe.infNFe.total.ICMSTot.vIPI.formato_danfe', top=1*cm, left=20.2*cm, width=4.4*cm, height=0.6*cm)
        fld.padding_top = 0.18*cm
        
        # Fundo destacado do total da NF
        self.elements.append(Rect(top=1*cm, left=24.6*cm, height=0.6*cm, width=4.8*cm, stroke=False, stroke_width=0, fill=True, fill_color=HexColor(0xd0d0d0)))
        lbl, fld = self.inclui_campo_numerico(nome='clc_vnf', titulo=u'VALOR TOTAL DA NOTA', conteudo=u'NFe.infNFe.total.ICMSTot.vNF.formato_danfe', top=1*cm, left=24.6*cm, width=4.8*cm, height=0.6*cm, margem_direita=True)
        fld.padding_top = 0.18*cm
        lbl.style = DESCRITIVO_CAMPO_NEGRITO
        fld.style = DADO_CAMPO_NUMERICO_NEGRITO

        self.height = 1.6*cm 
开发者ID:thiagopena,项目名称:PySIGNFe,代码行数:40,代码来源:danfepaisagem.py

示例7: convertColor

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
def convertColor(self, svgAttr):
        "Convert string to a RL color object."

        # This needs also to lookup values like "url(#SomeName)"...

        text = svgAttr
        if not text or text == "none":
            return None

        if text == "currentColor":
            return "currentColor"
        if len(text) in (7, 9) and text[0] == '#':
            color = colors.HexColor(text, hasAlpha=len(text) == 9)
        elif len(text) == 4 and text[0] == '#':
            color = colors.HexColor('#' + 2*text[1] + 2*text[2] + 2*text[3])
        elif len(text) == 5 and text[0] == '#':
            color = colors.HexColor(
                '#' + 2*text[1] + 2*text[2] + 2*text[3] + 2*text[4], hasAlpha=True
            )
        else:
            # Should handle pcmyk|cmyk|rgb|hsl values (including 'a' for alpha)
            color = colors.cssParse(text)
            if color is None:
                # Test if text is a predefined color constant
                try:
                    color = getattr(colors, text)
                except AttributeError:
                    pass
        if color is None:
            logger.warning("Can't handle color: %s" % text)
        else:
            return self.color_converter(color) 
开发者ID:deeplook,项目名称:svglib,代码行数:34,代码来源:svglib.py

示例8: new_title_bar

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
def new_title_bar(self, title, color=None):
        """Return an array of Pdf Objects which constitute a Header"""
        # Build a title bar for top of page
        w, t, c = '100%', 2, color or HexColor('#404040')
        title = '<b>{0}</b>'.format(title)
        if 'TitleBar' not in self.stylesheet:
            tb = ParagraphStyle('TitleBar', parent=self.stylesheet['Normal'], fontName='Helvetica-Bold', fontSize=10,
                                leading=10, alignment=TA_CENTER)
            self.stylesheet.add(tb)
        return [HRFlowable(width=w, thickness=t, color=c, spaceAfter=2, vAlign='MIDDLE', lineCap='square'),
                self.new_paragraph(title, 'TitleBar'),
                HRFlowable(width=w, thickness=t, color=c, spaceBefore=2, vAlign='MIDDLE', lineCap='square')] 
开发者ID:bpsmith,项目名称:tia,代码行数:14,代码来源:builder.py

示例9: heat_map

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
def heat_map(self, cmap='RdYlGn', vmin=None, vmax=None, font_cmap=None):
        if cmap is None:
            carr = ['#d7191c', '#fdae61', '#ffffff', '#a6d96a', '#1a9641']
            cmap = LinearSegmentedColormap.from_list('default-heatmap', carr)

        if isinstance(cmap, basestring):
            cmap = get_cmap(cmap)
        if isinstance(font_cmap, basestring):
            font_cmap = get_cmap(font_cmap)

        vals = self.actual_values.astype(float)
        if vmin is None:
            vmin = vals.min().min()
        if vmax is None:
            vmax = vals.max().max()
        norm = (vals - vmin) / (vmax - vmin)
        for ridx in range(self.nrows):
            for cidx in range(self.ncols):
                v = norm.iloc[ridx, cidx]
                if np.isnan(v):
                    continue
                color = cmap(v)
                hex = rgb2hex(color)
                styles = {'BACKGROUND': HexColor(hex)}
                if font_cmap is not None:
                    styles['TEXTCOLOR'] = HexColor(rgb2hex(font_cmap(v)))
                self.iloc[ridx, cidx].apply_styles(styles)
        return self 
开发者ID:bpsmith,项目名称:tia,代码行数:30,代码来源:table.py

示例10: title_bar

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
def title_bar(self, title):
        # Build a title bar for top of page
        w, t, c = '100%', 2, HexColor('#404040')
        title = '<b>{0}</b>'.format(title)
        return [HRFlowable(width=w, thickness=t, color=c, spaceAfter=2, vAlign='MIDDLE', lineCap='square'),
                self.pdf.new_paragraph(title, 'TitleBar'),
                HRFlowable(width=w, thickness=t, color=c, spaceBefore=2, vAlign='MIDDLE', lineCap='square')] 
开发者ID:bpsmith,项目名称:tia,代码行数:9,代码来源:pdf_rpts.py

示例11: sample1

# 需要导入模块: from reportlab.lib import colors [as 别名]
# 或者: from reportlab.lib.colors import HexColor [as 别名]
def sample1():
    pdf_path = os.path.join(tempfile.gettempdir(), 'pdf_test_4.pdf')
    cols = ['pct', 'int', 'k', 'M', '$', 'date']
    df = pd.DataFrame(np.random.randn(40, len(cols)), columns=cols)
    df['int'] = 10000. * df['pct']
    df['k'] = 50000. * df['pct']
    df['M'] = 5000000. * df['pct']
    df['$'] = 500000. * df['pct']
    df['date'] = pd.date_range('1/1/2010', periods=len(df.index))
    df['id'] = 'ID-1'
    # Make this a multi-index frame
    df2 = df.copy()
    df2['id'] = 'ID-2'
    df = df.set_index('id', append=True).unstack().reorder_levels([1, 0], axis=1)
    df2 = df2.set_index('id', append=True).unstack().reorder_levels([1, 0], axis=1)
    aggdf = pd.concat([df, df2], axis=1)
    # Start building the pdf
    pdf = PdfBuilder(pdf_path)
    # build the templates to use
    gt = GridTemplate('T1', 100, 100)
    gt.define_frames({
        'HEADER': gt[:10, :],
        'TBL': gt[10:],
    })
    gt.register(pdf)

    # Build the pdf tables to marry with the template
    def make_builder(hdr=1, idx=1, cstyles=None):
        tf = TableFormatter(aggdf, inc_header=hdr, inc_index=idx)
        tf.apply_default_style(index_override={'BACKGROUND': colors.beige})
        tf.header.detect_colspans()
        tf.header.apply_style('ALIGN', 'CENTER')
        tf.cells.match_any_labels('pct').apply_number_format(PercentFormatter)
        tf.cells.match_any_labels('k').apply_number_format(ThousandsFormatter)
        tf.cells.match_any_labels('int').apply_number_format(IntFormatter)
        tf.cells.match_any_labels('M').apply_number_format(MillionsFormatter)
        tf.cells.match_any_labels('$').apply_number_format(DollarCentsFormatter)

        def red_weekend(x):
            if x.dayofweek in (5, 6):
                return dict(BACKGROUND=colors.HexColor("#800000"), TEXTCOLOR=colors.white)

        tf.cells.match_any_labels('date').apply(format=fmt.Y_m_dFormatter, cstyles=red_weekend)
        return tf

    # Build PDF
    for hon, ion in list(itertools.product([True, False], repeat=2)):
        offon = lambda v: v and 'On' or 'Off'
        for cstyle in [None, ConditionalRedBlack]:
            hdr = 'Index=%s Header=%s Color=%s' % (offon(ion), offon(hon), offon(cstyle is not None))
            data = {
                'HEADER': Paragraph(hdr, getSampleStyleSheet()['Normal']),
                'TBL': make_builder(hon, ion, cstyle).build(),
            }
            pdf.build_page('T1', data)
    pdf.save()
    print pdf_path 
开发者ID:bpsmith,项目名称:tia,代码行数:59,代码来源:sample.py


注:本文中的reportlab.lib.colors.HexColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。