QRGenerator Update
I decided to update the QR Generator to now place the generated QR codes into its own folder rather than cluttering wherever you downloaded the program.
The update is now on GitHub
https://github.com/stephenwilde247/qrgenerator
All QR codes now go into a folder called generatedqr
. The program even checks to see if you have the folder on your computer; if not, it will create it. It will also output the location of your generatedqr
folder.
Here is the updated code:
import qrcode
import os.path
def qr_create():
os.chdir('generatedqr')
location = os.getcwd()
# 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 = int(input())
if qrcodeFExt == 1:
img.save(qrcodeFName + "." + (ext[0]))
print("Saved as " + qrcodeFName + "." + (ext[0]))
print(f"in location directory: {location}")
elif qrcodeFExt == 2:
img.save(qrcodeFName + "." + (ext[1]))
print("Saved as " + qrcodeFName + "." + (ext[1]))
print(f"in location directory: {location}")
elif qrcodeFExt == 3:
img.save(qrcodeFName + "." + (ext[2]))
print("Saved as " + qrcodeFName + "." + (ext[2]))
print(f"in location directory: {location}")
else:
print("Cannot save as file extension is not valid")
# Step 4: Completion message
print("Done")
is_file_there = os.path.exists('generatedqr')
if is_file_there:
print("Nothing to do as 'generatedqr' exists. Starting QR code Generator.")
qr_create()
else:
print("Creating folder 'generatedqr'")
os.mkdir("generatedqr")
qr_create()