Skip to content

Instantly share code, notes, and snippets.

@ayersdecker
Last active October 25, 2023 21:14
Show Gist options
  • Save ayersdecker/24422ab2ef9f9aecb0d8e98199d3996b to your computer and use it in GitHub Desktop.
Save ayersdecker/24422ab2ef9f9aecb0d8e98199d3996b to your computer and use it in GitHub Desktop.
Simple QR tools to use with Python code, works best on Raspberry Pi 4

Easy Resources to Include QR to Python code

Compiled by: Decker Ayers Github: https://github.com/ayersdecker/PiQRScan-Py

Installing

sudo apt-get update
sudo apt-get install python-qrtools

[sudo] pip install pypng
[sudo] pip install zbar
[sudo] pip install pillow

Generate a QR Code

Import Statment

from qrtools import QR

import os
my_QR = QR(data = u"Example")
my_QR.encode()

Command to move the QR code to the desktop

os.system("sudo mv " + my_QR.filename + " ~/Desktop")

Read a QR Code

Import Statment

from qrtools import QR
my_QR = QR(filename = "home/user/Desktop/qr.png")

Decodes the QR code and returns True if successful

my_QR.decode()

Prints the data

print (my_QR.data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment