How can I compile Python 3.8 on macOS this QR code

216 views Asked by At

I am absolutely new to working with Python. Please help me compile to a standalone .app program attached below to create a simple QRcode from the clipboard. Or is it the wrong way and should I use java?

    import clipboard
    import qrcode
    import os
    import reportlab.lib.pagesizes
    from reportlab.pdfgen import canvas
    
    numer = clipboard.paste()
    nazwajpg = numer + '.jpg'
    nazwapdf= numer + "_id.pdf"
    
    qr = qrcode.QRCode(
        version=1,
        box_size=15,
        border=3
    )
    
    data = numer
    qr.add_data(data)
    qr.make(fit=True)
    img = qr.make_image(fill='black', back_color='white')
    img.save(nazwajpg)
        
    def hello(c):
        c.drawImage(nazwajpg, 12, 0, width=125, height=125)
        c.setFont("Helvetica-Bold", size=28)
        c.drawCentredString(76, 122, numer)
    c = canvas.Canvas(nazwapdf, pagesize=QR)
    
    hello(c)
    c.showPage()
    c.save(nazwapdf)
    
    os.remove(nazwajpg)
1

There are 1 answers

0
Raunanza On

The best way, as I know, is to use pyinstaller-- https://www.pyinstaller.org/ . This helped me create a windows executable and it should work with mac too.