Making QR codes from Python

I’m trying to create the game of robot rugby. As you do. I’ve no idea how the game mechanic will work. My plan is to rope in some folks at the Hardware Meetup to try and work out the rules.

Anyhoo, one of the things that we are working on is some way of tracking the robots around the playfield so that each robot player can know where it is. Brian has been working on some code to track things by means of QR codes and so I said I’d make some “rugby hats” for the robots with QR codes printed on them. So I needed to get and print some QR codes.

It turns out that making QR codes from a Python program is really, really easy. I found this library which works a treat.

import qrcode
for i in range(1,25):
    qr = qrcode.QRCode(
    version=1,
    error_correction=qrcode.constants.ERROR_CORRECT_L,
    box_size=5,
    border=4,
    )
    text="Robot"+str(i)
    qr.add_data(text)
    qr.make()
    img = qr.make_image(fill_color="black", back_color="white")
    filename = text+".png"
    img.save(filename)

This will make 24 labels that will just fill an A4 page in a word document. I printed them out onto label paper and stuck them on some pixel shades that I’d printed.