QRcode Generator Python
I use QR codes a lot for many different projects and can’t really be bothered using an online generator, so I made one a while ago and use it a lot. I wanted to share it with you. Feel free to try it out! The source code is below:
This project is now on GitHub
https://github.com/stephenwilde247/qrgenerator
import qrcode
# Welcome message
welcome = "Welcome to this QR generator by stephenwilde.net"
# List for file extensions
ext = ["jpg", "png", "gif"]
# Step 1: Text of QR code
print(welcome)
print("Enter your QRcode TXT")
qrcodeInput = input()
# Step 2: File Name
print("Enter the name of the image")
qrcodeFName = input()
# Replaces all empty strings with _ for a reason! Just sayin'
qrcodeFName = qrcodeFName.replace(" ", "_")
img = qrcode.make(qrcodeInput)
# Step 3: File extension
print("Please enter a number for your file extension\n1 for jpg\n2 for png\n3 for gif")
qrcodeFExt = input()
qrcodeFExt = int(qrcodeFExt)
if qrcodeFExt == 1:
img.save(qrcodeFName + "." + (ext[0]))
print("Saved as " + qrcodeFName + "." + (ext[0]))
elif qrcodeFExt == 2:
img.save(qrcodeFName + "." + (ext[1]))
print("Saved as " + qrcodeFName + "." + (ext[1]))
elif qrcodeFExt == 3:
img.save(qrcodeFName + "." + (ext[2]))
print("Saved as " + qrcodeFName + "." + (ext[2]))
else:
print("Cannot save as file extension is not valid")
# Step 4: It's obvious
print("Done")