How labbots/niimprintx works
Project Type and Purpose
• NiimPrintX is a cross-platform Python desktop application and library that provides both a Command-Line Interface (CLI) and a Graphical User Interface (GUI) for designing and printing labels on NiimBot Bluetooth printers.
• It wraps low-level Bluetooth protocols and printer-specific packet formats in a “nimmy” core, and exposes high-level commands (CLI) and interactive design widgets (GUI).
File Structure
Top-level directories and their roles:
• NiimPrintX/cli: Entry point for the CLI, using Click for command dispatch (info, print).
• NiimPrintX/nimmy: Core library for printer connectivity, packet construction, Bluetooth I/O, error handling, logging.
• bin, docs, assets/images: Supporting scripts (e.g., image preprocessing), documentation, sample media.
• spec_files and .github/workflows: Build/deployment definitions for Windows, macOS, Linux (PyInstaller specs, CI workflows).
README for Additional Insights
• Confirms Python 3.12+, ImageMagick dependency, Poetry for packaging.
• Highlights two user-facing interfaces (CLI and GUI), Bluetooth connectivity, supported printer models, and advanced print settings.
Main Components & Their Relationships
a. User Interfaces
• CLI App (NiimPrintX.cli)
• GUI App (NiimPrintX.ui)
b. Core Library
• Printer Abstraction Layer (nimmy.printer)
• Packet Builder (nimmy.packet)
• Bluetooth Transport (nimmy.bluetooth)
• Helpers (nimmy.helper) and Logging (nimmy.logger_config)
c. External Dependencies
• ImageMagick (image processing)
• Bluetooth stack (OS-level/Bluetooth library)
d. Target Hardware
• NiimBot printers (models D11, B21, B1, D110, B18)
Architectural Patterns & Design Principles
• Layered architecture: UI/CLI → Core Library → Transport → Hardware
• Single Responsibility: Each nimmy submodule focuses on one aspect (packet, transport, printer model).
• Modularity: CLI and GUI are thin presentation layers reusing the same core.
• Cross-platform packaging via PyInstaller specs and CI workflows.
Detailed Coverage
• Build pipeline: GitHub Actions → PyInstaller specs → platform installers.
• Helper scripts (bin/process_png.py) as part of the image-prep sub-flow.