A small, production‑quality desktop app for generating QR codes from any text or URL.
- Preview instantly and save as PNG (white or transparent background) or SVG.
- Cross‑platform: Windows, macOS, Linux.
Keyboard shortcuts
| Action | Shortcut |
|---|---|
| Generate | Ctrl+G |
| Save | Ctrl+S |
| Clear | Esc |
Error correction: L / M / Q / H Backgrounds (PNG): White or Transparent
text-to-qr/
├─ pyproject.toml
├─ README.md
├─ .gitignore
└─ src/
└─ qrstudio/
├─ __init__.py
├─ main.py # Allows: python -m qrstudio
├─ config.py # App configuration (dataclass)
├─ events.py # Minimal event bus (Observer)
├─ commands.py # Generate/Save commands (Command pattern)
├─ domain/
│ ├─ __init__.py
│ ├─ spec.py # QRSpec + ErrorCorrection (domain model)
│ └─ backgrounds.py# Background strategies (Strategy)
├─ encoding/
│ ├─ __init__.py
│ └─ encoders.py # PNG/SVG encoders (Factory)
├─ services/
│ ├─ __init__.py
│ └─ qr_service.py # Pure service: build/render/save QR
└─ ui/
├─ __init__.py
└─ tk_app.py # Tkinter GUI (thin layer over commands)
If your actual package files are named
init.py, rename them to__init__.pyto make the packages importable.
- Domain → Services → UI layering keeps logic testable and the UI swappable.
- Command pattern isolates actions; the UI only wires callbacks.
- Strategy for background (white/transparent); Factory for encoders (PNG/SVG).
- EventBus (Observer) decouples logging/console from actions.
- Python ≥ 3.9
- Platforms: Windows, macOS, Linux (Tkinter is included in python.org installers)
- Dependencies:
qrcode[pil],Pillow(installed viapyproject.toml)
From the project root (the folder containing pyproject.toml).
Windows (PowerShell)
python -m venv .venv
.\.venv\Scripts\Activate.ps1macOS / Linux (bash/zsh)
python3 -m venv .venv
source .venv/bin/activatepython -m pip install --upgrade pip
python -m pip install -e .Option A: module entry
python -m qrstudioOption B: console script (from pyproject.toml)
qrstudioThe window opens. Enter your text/URL, choose White or Transparent (PNG), click Generate, then Save… to export PNG or SVG.
Launch without an attached console (Windows):
pythonw -m qrstudio-
Transparent PNG: choose Transparent (PNG) before generating. Saving as SVG always uses a transparent canvas (vector).
-
Error correction:
- L (≈7%), M (≈15%), Q (≈25%), H (≈30%) — higher = more robust, larger codes.
-
Box size & border control pixel density and quiet zone.
-
ModuleNotFoundError: qrcodeorPILRe‑run:python -m pip install -e . -
Tkinter errors (e.g.,
_tkinter/init.tcl) Install Python from python.org (includes Tcl/Tk). On Linux, you may need your distro’s Tk package, e.g.:sudo apt-get install python3-tk
-
Nothing happens on Save Generate first, then use Save…. Ensure the path ends with .png or .svg.