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


Python Drawing.scale方法代码示例

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


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

示例1: barChart

# 需要导入模块: from reportlab.graphics.shapes import Drawing [as 别名]
# 或者: from reportlab.graphics.shapes.Drawing import scale [as 别名]
def barChart(daten,Versuch,Phaenomene,path=None,vMin=1,vMax=6):
    """
    Plots data to a Drawing and returns the Drawing
    """
    #Festlegen der Gesamtgröße in Pixel
    d = Drawing(500,160)
    #Daten für das Diagramm
    #daten = [(10,6,8)]
    #Anlegen des Diagramms
    diagramm = HorizontalBarChart()
    #Positionierung und Größe des Diagramms
    diagramm.x = 10
    diagramm.y = 30
    diagramm.height = 100
    diagramm.width = 400
    #Hinzufügen der Daten
    #diagramm.reversePlotOrder = 1
    diagramm.data = daten
    #Y-Achse (in ReportLab „valueAxis“) formatieren
    diagramm.valueAxis.valueMin = vMin
    diagramm.valueAxis.valueMax = vMax
    diagramm.valueAxis.valueStep = 1
    #X-Achse (in ReportLab „categoryAxis“) formatieren
    diagramm.categoryAxis.categoryNames = Phaenomene
    #Diagramm zeichnen
    d.add(diagramm)
    if not path == None:
        Versuch = path + Versuch    
    renderPM.drawToFile(d, Versuch + ".png", 'PNG')    
    #d = Paragraph(d, centered)
    d.scale(0.8,0.8)
    
    return d
开发者ID:MarkusFries,项目名称:mubosym,代码行数:35,代码来源:autoreport.py

示例2: test2

# 需要导入模块: from reportlab.graphics.shapes import Drawing [as 别名]
# 或者: from reportlab.graphics.shapes.Drawing import scale [as 别名]
    def test2(self):
        "Test scaled Image shape adding it to a PDF page."

        inPath = IMAGENAME
        img = Image(0, 0, 110, 44, inPath)
        d = Drawing(110, 44)
        d.add(img)
        d.translate(120, 0)
        d.scale(2, 2)
        IMAGES.append(d)
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:12,代码来源:test_graphics_images.py

示例3: test3

# 需要导入模块: from reportlab.graphics.shapes import Drawing [as 别名]
# 或者: from reportlab.graphics.shapes.Drawing import scale [as 别名]
    def test3(self):
        "Test rotated Image shape adding it to a PDF page."

        inPath = IMAGENAME
        img = Image(0, 0, 110, 44, inPath)
        d = Drawing(110, 44)
        d.add(img)
        d.translate(420, 0)
        d.scale(2, 2)
        d.rotate(45)
        IMAGES.append(d)

        IMAGES.append(None) # used to indicate last test
开发者ID:ShaulBarkan,项目名称:PRION,代码行数:15,代码来源:test_graphics_images.py

示例4: get_barcode

# 需要导入模块: from reportlab.graphics.shapes import Drawing [as 别名]
# 或者: from reportlab.graphics.shapes.Drawing import scale [as 别名]
    def get_barcode(self, value, width, barWidth = 0.05 * units.inch,
                    fontSize = 12, humanReadable = True):
        # El valor por default de fontSize=60
        barcode = createBarcodeDrawing('Code128', value = value, barWidth = barWidth, fontSize = fontSize, humanReadable = humanReadable)
        drawing_width = width
        barcode_scale = drawing_width / barcode.width
        drawing_height = barcode.height * barcode_scale

        drawing = Drawing(drawing_width, drawing_height)
        drawing.scale(barcode_scale, barcode_scale)
        drawing.add(barcode, name='barcode')
        barcode_encode = b64encode(renderPM.drawToString(drawing, fmt = 'PNG'))
        barcode_str = '<img style="width:320px;height:80px;"  src="data:image/png;base64,{0} : ">'.format(barcode_encode)
        return barcode_str
开发者ID:OpenBusinessSolutions,项目名称:odoo-fondeur-server,代码行数:16,代码来源:obs_mrp_small_label_template.py

示例5: get_barcode

# 需要导入模块: from reportlab.graphics.shapes import Drawing [as 别名]
# 或者: from reportlab.graphics.shapes.Drawing import scale [as 别名]
def get_barcode(value, width, humanReadable = True):

    #value = value.encode('ascii', 'ignore')
    value = unidecode(value)
    barcode = createBarcodeDrawing('Code128', value = value, humanReadable = humanReadable, fontSize = 8)

    drawing_width = width
    barcode_scale = drawing_width / barcode.width
    drawing_height = barcode.height * barcode_scale

    drawing = Drawing(drawing_width, drawing_height)
    drawing.scale(barcode_scale, barcode_scale)
    drawing.add(barcode, name='barcode')

    return drawing
开发者ID:javierwilson,项目名称:forocacao,代码行数:17,代码来源:png.py

示例6: createBarcodeDrawing

# 需要导入模块: from reportlab.graphics.shapes import Drawing [as 别名]
# 或者: from reportlab.graphics.shapes.Drawing import scale [as 别名]
    c.setPageSize((width, height))
    for element in page['elements']:
        element_type = element.setdefault('type', 'text')
        fontSize = element.setdefault('fontSize', 10)
        fontType = element.setdefault('fontType', 'Courier')
        element_width = element.setdefault('width', 30)
        element_height = element.setdefault('height', 30)
        text = element.setdefault('text', '')
        if element_type == "barcode":
            barcode = createBarcodeDrawing(
                'Code128', height=element_height, value=text, barWidth=1, humanReadable=True)
            drawing_width = element_width
            barcode_scale = drawing_width / barcode.width
            drawing_height = barcode.height * barcode_scale
            drawing = Drawing(drawing_width, drawing_height)
            drawing.scale(barcode_scale, barcode_scale)
            drawing.add(barcode, name='barcode')
            c.setFont(fontType, fontSize)
            renderPDF.draw(drawing, c, element['x'], element['y'])
        elif element_type == "text":
            text_width = stringWidth(text, fontType ,fontSize )
            font_ratio = element_width/text_width
            if (font_ratio<=1):
                fontSize = fontSize*font_ratio
                pprint(font_ratio)


            c.setFont(fontType, fontSize)
            c.drawString(element['x'], element['y'], element['text'])
    c.showPage()
c.save()
开发者ID:enyachoke,项目名称:JsonLabels,代码行数:33,代码来源:generate.py


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