Skip to content

Repository files navigation

pyqtrapid

Build Status PyPI Version License: MIT Python Versions

pyqtrapid is a CLI scaffolding framework and architecture generator for Python desktop applications built with PyQt and PySide.

It streamlines the creation of maintainable, testable, and production-ready GUI applications by establishing architectural separation of concerns, multi-binding abstraction, threading utilities, theme management, component generation, and standard packaging out of the box.


Key Features

  • Multi-Binding Compatibility: Native support for PyQt6, PySide6 (Official Qt for Python 6), and PyQt5.
  • Architecture Scaffolds:
    • MVP (Model-View-Presenter): Decoupled presentation logic, ideal for enterprise desktop applications.
    • MVVM (Model-View-ViewModel): Reactive view-model binding pattern for data-driven UIs.
    • Minimal: Lightweight structure for rapid prototyping.
  • Component Generators: CLI commands to scaffold individual Views, Models (with unit tests), Dialogs, and Presenters on demand.
  • Executable Packaging Scaffolds: Instant setup for PyInstaller (.spec) and Nuitka C++ standalone executable builds.
  • Asynchronous Thread Pool: Built-in non-blocking background task runner utilizing QThreadPool and QRunnable.
  • Theme System: Integrated QSS styling engine supporting light/dark theme switching and QSettings persistence.
  • Testing & Diagnostics: Pre-configured pytest suite and structured logging infrastructure.

Installation

Install pyqtrapid using pip:

pip install pyqtrapid

To install from source for development:

git clone https://github.com/edeniyanda/pyqtrapid.git
cd pyqtrapid
pip install -e .

CLI Command Reference

1. Project Scaffolding (startproject)

Scaffold a complete application directory:

pyqtrapid startproject <project_name> [options]
Option Short Default Description
--binding -b pyqt6 Qt Python binding (pyqt6, pyside6, pyqt5)
--template -t mvp Architectural template (mvp, mvvm, minimal)
--force -f false Overwrite target directory if it already exists

2. Component Scaffolding (generate)

Generate modular components inside an existing project:

pyqtrapid generate <type> <name> [options]
Component Type Description Output Files
view Qt Widget View src/views/<name>_view.py
model Domain Model & Unit Test src/models/<name>_model.py
tests/test_<name>_model.py
dialog Modal Dialog (QDialog) src/views/<name>_dialog.py
presenter Presenter Controller src/presenters/<name>_presenter.py

3. Packaging Configuration (build-config)

Scaffold production build files for single-file executable bundling:

# Generate PyInstaller build specification
pyqtrapid build-config --tool pyinstaller --name my_app

# Generate Nuitka C++ standalone build script
pyqtrapid build-config --tool nuitka --name my_app

Quick Start Examples

Scaffold an MVP Project with PyQt6 (Default)

pyqtrapid startproject desktop_app

Scaffold an MVVM Project with PySide6

pyqtrapid startproject analytics_dashboard --binding pyside6 --template mvvm

Generate Components Inside Existing Project

cd desktop_app

# Generate a User Profile Model with tests
pyqtrapid generate model user_profile

# Generate a Settings View
pyqtrapid generate view settings

# Generate a Custom Login Dialog
pyqtrapid generate dialog login

Directory Structure Overview

Generated projects adhere to clean separation of concerns:

desktop_app/
├── main.py                   # Application entry point & Qt event loop
├── pyproject.toml            # Package metadata & test configuration
├── src/
│   ├── app.py                # Dependency injection & view factory
│   ├── core/                 # App config, logging, and async worker pool
│   │   ├── config.py
│   │   ├── logger.py
│   │   └── worker.py
│   ├── models/               # Domain state & business logic (pure Python)
│   ├── views/                # Qt Widgets & UI layout definitions
│   ├── presenters/           # Presentation logic connecting Views & Models
│   └── resources/            # Stylesheets (QSS) and static assets
│       └── styles/
│           ├── dark.qss
│           └── light.qss
├── ui/                       # Qt Designer (.ui) XML files
└── tests/                    # Unit tests and view suite (pytest)

Running and Testing Scaffolded Applications

Navigate to your generated project directory and run the application:

cd desktop_app
pip install -e .
python main.py

Run the automated test suite:

pytest

Contributing

Contributions, issue reports, and feature suggestions are welcome. Please refer to CONTRIBUTING.md to get started.


License

pyqtrapid is released under the MIT License.

About

A Python package that simplifies the initiation of PyQt5 projects, providing a one-command solution to generate comprehensive starter files for quick and efficient project customization.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages