A modern, production-ready desktop application for generating and printing Code128 barcodes and QR codes on Windows. Built with Python and Flet for a beautiful native experience with threaded printing and atomic file operations.
- 🎯 Simple Interface - Clean, Material Design 3 interface for quick barcode printing
- 📱 Dual Code Support - Generate both Code128 barcodes and QR codes
- ⌨️ Barcode Scanner Support - Scan barcodes directly with USB/Bluetooth scanners
- 🖨️ Multi-Printer Support - Select from any installed Windows printer
- 👁️ Preview - See your barcode/QR code before printing with async generation
- 📊 Print History - Track all printed codes with timestamps and type indicators
- 🔁 One-Click Reprint - Tap any history entry to copy it to the clipboard and text field, ready to reprint instantly
- 🗑️ Clear History - Contextual floating action button appears when history has entries to clear it in one tap
- 🏷️ Dynamic Print Button - Button label updates to "Print Barcode" or "Print QR Code" based on the selected code type
- 🎨 Dark/Light Mode - Choose your preferred theme with persistent settings
- 💾 Settings Persistence - Remembers your printer and theme preferences with atomic file writes
- ⚡ Performance Optimized - LRU cache with thread-safe access for instant code generation
- 🎯 Auto-Focus - Automatically re-focuses the input field on window focus and background click, always ready for the next scan
- 🧵 Threaded Printing - Non-blocking print operations keep UI responsive
- 📐 Smart Scaling - Auto-scales to 4 inches or page width, handles both dimensions
- 🔒 Thread-Safe - Proper locking for concurrent operations
- 💪 Robust Error Handling - Graceful handling of printer failures and invalid input with backward-compatible history entries
- 🎚️ Progress Indicator - Visual indeterminate progress bar during print with delayed auto-hide via
threading.Timer - 📐 DPI Aware Printing - Adapts to any printer resolution (300, 600, 1200+ DPI)
- 🖥️ Per-Monitor DPI Aware - Display renders sharply on high-DPI and multi-monitor setups via
SetProcessDpiAwareness - 🪟 Minimum Window Size - Enforces a 700×700px minimum to prevent layout breakage
- 🚫 Zero pywin32 Dependency - All printer access, clipboard, and GDI printing handled natively via
ctypes
The easiest way to get started is to download the pre-built installer directly from the Releases page. Run BarcodePrinter_Setup.exe and follow the prompts — no Python required.
Prerequisites: Python 3.10+
-
Clone the repository and install dependencies:
git clone https://github.com/dannyphamv/flet-barcode-printer.git cd flet-barcode-printer pip install -r requirements.txt -
Build the standalone Windows executable:
flet build windows
-
Create the installer with Inno Setup:
Download and install Inno Setup, then double-click
installer.issto open it in Inno Setup Compiler and click the Compile button.Your installer will be output to
installer_output\BarcodePrinter_Setup.exe.
- Select Code Type - Choose between Barcode or QR Code
- Enter/Scan Data - Type or scan your barcode data
- Preview (Optional) - Click Preview to see the generated code
- Select Printer - Choose your target printer from the dropdown
- Print - Click Print or press Enter
- Reprint - In the History tab, tap any row to copy the data to your clipboard and jump back to the Print tab ready to go
The app automatically:
- Generates high-quality codes optimized for 4-inch printing
- Scales to fit smaller label sizes
- Centers the code on the page
- Maintains aspect ratio
- Saves to print history
| Package | Version | Purpose |
|---|---|---|
| flet[all] | >=0.80.5 | Modern GUI framework |
| flet-datatable2 | >=0.80.5 | Enhanced data tables |
| python-barcode[images] | >=0.16.1 | Code128 barcode generation |
| qrcode[pil] | >=8.2 | QR code generation |
| Pillow | >=12.1.1 | Image processing & LANCZOS resampling |
pywin32is not required. Printer enumeration, GDI printing, and clipboard access are all handled through Python's built-inctypesmodule.
See requirements.txt for exact versions.
- Main Thread: Flet UI event loop
- Background Threads: Print operations run in daemon threads
- Thread Safety:
threading.Lockprotects LRU cache,page.run_thread()for UI updates - Non-blocking:
threading.Timerfor delayed progress bar hide instead oftime.sleep()
- Atomic Writes: Uses
tempfile.mkstemp()+os.replace()to prevent corruption - JSON Storage: Settings and history stored in
%APPDATA%/BarcodePrinter/ - Graceful Degradation: Handles corrupted files by returning defaults
- Backward-Compatible History: Old entries without a
code_typefield default to barcode automatically
- DPI Detection: Queries printer capabilities via
GetDeviceCaps()throughctypes - Dynamic Scaling: Calculates exact pixel dimensions based on printer DPI
- High-Quality Resampling: Uses Pillow's LANCZOS algorithm
- Overflow Protection: Checks both width and height constraints
This project is licensed under the MIT License - see the LICENSE file for details.
