🎨 Beautiful QR Code Generator
Create stunning, customizable QR codes with advanced styling options
import streamlit as st import qrcode from qrcode.image.styledpil import StyledPilImage from qrcode.image.styles.moduledrawers import RoundedModuleDrawer, CircleModuleDrawer, SquareModuleDrawer from qrcode.image.styles.colorfills import SolidFillColorMask, RadialGradiantColorMask, SquareGradiantColorMask from PIL import Image, ImageDraw import io import base64 # Page configuration st.set_page_config( page_title="QR Code Generator", page_icon="📱", layout="wide", initial_sidebar_state="expanded" ) # Custom CSS for beautiful styling st.markdown(""" """, unsafe_allow_html=True) def create_qr_code(data, fill_color, back_color, border, box_size, error_correction, style_type): """Generate QR code with custom styling""" # Error correction levels error_levels = { 'L (~7%)': qrcode.constants.ERROR_CORRECT_L, 'M (~15%)': qrcode.constants.ERROR_CORRECT_M, 'Q (~25%)': qrcode.constants.ERROR_CORRECT_Q, 'H (~30%)': qrcode.constants.ERROR_CORRECT_H } # Create QR code instance qr = qrcode.QRCode( version=1, error_correction=error_levels[error_correction], box_size=box_size, border=border, ) qr.add_data(data) qr.make(fit=True) # Style configurations if style_type == "Standard": img = qr.make_image(fill_color=fill_color, back_color=back_color) elif style_type == "Rounded": img = qr.make_image( image_factory=StyledPilImage, module_drawer=RoundedModuleDrawer(), fill_color=fill_color, back_color=back_color ) elif style_type == "Circular": img = qr.make_image( image_factory=StyledPilImage, module_drawer=CircleModuleDrawer(), fill_color=fill_color, back_color=back_color ) elif style_type == "Gradient": img = qr.make_image( image_factory=StyledPilImage, color_mask=RadialGradiantColorMask(), fill_color=fill_color, back_color=back_color ) return img def get_download_link(img, filename): """Generate download link for the QR code""" buffered = io.BytesIO() img.save(buffered, format="PNG") img_str = base64.b64encode(buffered.getvalue()).decode() href = f'📥 Download QR Code' return href # Main header st.markdown("""
Create stunning, customizable QR codes with advanced styling options
Your QR code is ready. Click below to download it as PNG.
🚀 Built with Streamlit | 💝 Made with love for QR code enthusiasts