BASE GENERATOR
Essential Widgets
import qrcode
from PIL import Image
# This QR Code Generator was developed by Robert Andrews, Beatitudes Resident.
xx = input("Enter URL: ")
xName = input("Enter QR Code File Name: ")
# Website URL
website_url = xx
# ERROR TRAP URL
xTRAP = xx[0:4]
if xTRAP == "http":
website_url = xx
else:
website_url = "http://" + xx
# ERROR TRAP FILENAME
if xName.endswith(".JPG") or xName.endswith(".PNG"):
xName = xName
else:
xName = xName+".JPG"
# Create QR code instance
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
# Add website URL to QR code
qr.add_data(website_url)
qr.make(fit=True)
# Create an image from the QR code with dark blue color
img = qr.make_image(fill_color="#295BB3", back_color="white") # Use hex code for dark blue
# Open the logo image
logo = Image.open("LOGO.png")
logo = logo.resize((59, 59)) # Resize the logo image if necessary
# Get the position to paste the logo in the center of the QR code image
position = ((img.size[0] - logo.size[0]) // 2, (img.size[1] - logo.size[1]) // 2)
# Paste the logo onto the QR code image
img.paste(logo, position)
# Save the QR code image with the logo
img.save(xName)
print ("QR Code is on the desktop under QR Code Generator.")