Files
adaptronic_label-printer/build_exe.py
NAME 839828340d Add template selection and multiple copy printing features
- Implemented template selection: type 0=OK (green), type 1=NOK (red)
- Added multiple copy printing (1-100 copies)
- Extended file format to 5 fields: ARTICLE;NR_ART;SERIAL;TYPE;COUNT
- Created OK/NOK SVG templates with visual distinction
- Fixed PDF landscape orientation issues
- Updated SumatraPDF to use noscale for exact dimensions
- Auto-generate conf folder with default templates on first run
- Made pystray optional for system tray functionality
- Updated build scripts for Python 3.13 compatibility (Kivy 2.3+, PyInstaller 6.18)
- Added comprehensive build documentation
- Improved printer configuration guidance
2026-02-13 23:34:59 +02:00

90 lines
3.0 KiB
Python

"""
PyInstaller build script for Label Printer GUI
Run this to create a standalone Windows executable
IMPORTANT: This script MUST be run on Windows to generate a Windows .exe file.
If run on Linux/macOS, it will create a Linux/macOS binary that won't work on Windows.
To build for Windows:
1. Copy this project to a Windows machine
2. Install dependencies: pip install -r requirements_windows.txt
3. Run this script: python build_exe.py
4. The Windows .exe will be created in the dist/ folder
"""
import os
import sys
import subprocess
# Get the current directory
script_dir = os.path.dirname(os.path.abspath(__file__))
# PyInstaller arguments
args = [
'label_printer_gui.py',
'--onefile', # Create a single executable
'--windowed', # Don't show console window
'--name=LabelPrinter', # Executable name
'--distpath=./dist', # Output directory
'--workpath=./build', # Work directory (was --buildpath)
'--hidden-import=kivy',
'--hidden-import=kivy.core.window',
'--hidden-import=kivy.core.text',
'--hidden-import=kivy.core.image',
'--hidden-import=kivy.uix.boxlayout',
'--hidden-import=kivy.uix.gridlayout',
'--hidden-import=kivy.uix.label',
'--hidden-import=kivy.uix.textinput',
'--hidden-import=kivy.uix.button',
'--hidden-import=kivy.uix.spinner',
'--hidden-import=kivy.uix.scrollview',
'--hidden-import=kivy.uix.popup',
'--hidden-import=kivy.clock',
'--hidden-import=kivy.graphics',
'--hidden-import=PIL',
'--hidden-import=barcode',
'--hidden-import=reportlab',
'--hidden-import=print_label',
'--hidden-import=print_label_pdf',
'--hidden-import=svglib',
'--hidden-import=cairosvg',
'--hidden-import=watchdog',
'--hidden-import=watchdog.observers',
'--hidden-import=watchdog.events',
'--hidden-import=pystray',
]
if __name__ == '__main__':
print("=" * 60)
print("Label Printer GUI - PyInstaller Build")
print("=" * 60)
print("\nBuilding standalone executable...")
print("This may take a few minutes...\n")
# Change to script directory
os.chdir(script_dir)
# Run PyInstaller directly with subprocess for better error reporting
try:
result = subprocess.run(['pyinstaller'] + args, check=True)
print("\n" + "=" * 60)
print("Build Complete!")
print("=" * 60)
print("\nExecutable location: ./dist/LabelPrinter.exe")
print("\nYou can now:")
print("1. Double-click LabelPrinter.exe to run")
print("2. Share the exe with others")
print("3. Create a shortcut on desktop")
print("\nNote: First run may take a moment as Kivy initializes")
except subprocess.CalledProcessError as e:
print("\n" + "=" * 60)
print("Build Failed!")
print("=" * 60)
print(f"\nError code: {e.returncode}")
print("\nPlease check the error messages above for details.")
sys.exit(1)
except Exception as e:
print(f"\nFatal error: {e}")
sys.exit(1)