Skip to content

Instantly share code, notes, and snippets.

@BomberFish
Created December 27, 2021 23:46
Show Gist options
  • Save BomberFish/b8153d32fbad8704b9b8d1406892c6ce to your computer and use it in GitHub Desktop.
Save BomberFish/b8153d32fbad8704b9b8d1406892c6ce to your computer and use it in GitHub Desktop.
The QR code generator I made some time ago, except it accepts files.
#importing pip like this will fail in the future, should be replaced.
for n in range(1):
try:
import pip
except ImportError as missing:
print("You don't have pip. Exiting...")
exit()
#install package function
def install(package):
pip.main(['install', package])
#qrcode module checker & install
for n in range(1):
try:
import qrcode
except ImportError as missing:
if input("You don't have the qrcode module. Install it now? [Y/n]").lower() == "y":
install(missing.name)
print("Please run the program again for changes to apply.")
exit()
else:
print("Abort.")
exit()
#data prompt
data = input("Enter the full or relative path of the PLAINTEXT file you want to convert: ")
file = open(data, "r")
#convert to qr code
output = qrcode.make(file.read())
#ask filename to save as
saveas = input("What do you want the file to be called? ")
#save file
output.save(saveas + ".png")
#print filename
print("Saved as " + saveas + ".png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment