Exemplo n.º 1
0
def qrcode_example_to_SVGElement():

    # The dimensions of the QR-Code
    width, height = 100, 100

    # Make an SVG root element
    from newskylabs.graphics.svg.svg import SVGElement
    root = SVGElement.root(width=width, height=height, absolute=True)

    # Make an QR-Code SVG element
    data = get_example_data(ex=0)
    qrcode = QRCode(data)
    qrcode_svg_element = qrcode.to_SVGElement(x=0,
                                              y=0,
                                              width=width,
                                              height=height)

    # Append the QR-Code SVG element to the SVG root element
    root.append(qrcode_svg_element)

    # Get a temporary file name
    import tempfile
    _, svgfile = tempfile.mkstemp(suffix='.svg',
                                  prefix='qrcode.',
                                  dir='/tmp',
                                  text=True)

    # Save the SVG file
    root.save(svgfile)

    # And finally open it
    application = 'Google Chrome'
    open_file(svgfile, application=application)
Exemplo n.º 2
0
def qrcode_save_and_show(itype='png'):
    data = get_example_data(ex=0)
    qrcode = QRCode(data)
    img = qrcode.to_img()
    filename = '/tmp/qr-code.{}'.format(itype)
    img.save(filename)
    open_file(filename)
def vcard_example_to_QRCode_jpg():
    data = get_example_data(ex=0)
    vc = VCard(data)
    qr_code = vc.to_QRCode()
    qr_code_img = qr_code.to_img()
    qr_code_file = '/tmp/qr-code.jpg'
    qr_code_img.save(qr_code_file)
    from newskylabs.graphics.utils.general import open_file
    open_file(qr_code_file)
Exemplo n.º 4
0
def qrcode_to_svg(method=None):
    data = get_example_data(ex=0)
    qrcode = QRCode(data)
    img = qrcode.to_img(itype='svg', method=method)
    if method == None:
        img.show()

    else:
        # The methods 'basic', 'fragment', and 'path'
        # do not have a 'show()' method:
        import tempfile
        _, filename = tempfile.mkstemp(suffix='.svg',
                                       prefix='qrcode.',
                                       dir='/tmp',
                                       text=True)
        img.save(filename)
        application = 'Google Chrome'
        open_file(filename, application=application)
Exemplo n.º 5
0
def qrcode_example_to_img():
    data = get_example_data(ex=0)
    qrcode = QRCode(data)
    img = qrcode.to_img()
    img.show()
Exemplo n.º 6
0
def qrcode_example_print_example_data():
    data = get_example_data(ex=0)
    print(data)
def vcard_example_pretty_print():
    data = get_example_data(ex=0)
    vc = VCard(data)
    vc.pretty_print()
def vcard_example_print_raw():
    data = get_example_data(ex=0)
    vc = VCard(data)
    vc.print(raw=True)