Metadata-Version: 2.4
Name: pyqt6-template-widgets
Version: 0.3.0
Summary: Template-based widgets and form helpers for PyQt6 applications
Author: proov
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: User Interfaces
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: PyQt6>=6.6
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: build>=1; extra == "dev"
Requires-Dist: twine>=5; extra == "dev"

# pyqt6-template-widgets

Template-based widgets and form helpers for PyQt6 applications. The library
helps build simple data-driven interfaces from reusable card, list and form
templates.

- `CardTemplate` — card layout in a list;
- `FormTemplate` and `FormField` — add/edit form;
- `TemplateListPage` — list with search, filter, sort, CRUD;
- `PageManager` — switch between login and list screens;
- partner-management preset on top of the template widgets;
- calculation helpers for sample business rules.

## Installation

```bash
pip install pyqt6-template-widgets
```

## Template window

```python
from pyqt6_templates import CardTemplate, FormField, FormTemplate, TemplateListWindow

items = [
    {
        "partner_type": "Дилер",
        "name": "ООО Ромашка",
        "director": "Иванов Иван Иванович",
        "phone": "+7 223 322 22 32",
        "rating": 10,
        "discount": 10,
    }
]

card_template = CardTemplate(
    title="{partner_type} | {name}",
    lines=["{director}", "{phone}", "Рейтинг: {rating}"],
    badge="{discount}%",
)

form_template = FormTemplate(
    title_create="Добавить партнера",
    title_edit="Редактировать партнера",
    fields=[
        FormField("name", "Наименование:", required=True),
        FormField("partner_type", "Тип:", kind="choice", choices=["Дилер", "Оптовик"]),
        FormField("rating", "Рейтинг:", kind="number", minimum=0),
        FormField("director", "Директор:", required=True),
        FormField("phone", "Телефон:", required=True),
    ],
)

window = TemplateListWindow(
    title="Список партнеров",
    items=items,
    card_template=card_template,
    form_template=form_template,
)
window.run()
```

See `examples/template_window.py`.

## Full shoe store app (login + products + orders)

After install:

```bash
pip install pyqt6-template-widgets
pyqt6-shoe-store
```

Other ways to run:

```bash
python -m pyqt6_templates.apps
python -m pyqt6_templates.apps.shoe_store
```

Open the application source (login, list pages, main window):

```bash
python -c "from pyqt6_templates.apps import app_source_path; print(app_source_path())"
```

Test accounts: `client1/123`, `manager1/123`, `admin1/123`, or guest login.

From a git checkout:

```bash
python examples/shoe_store.py
```

## Partner preset

```python
from pyqt6_templates import Partner, PartnerListWindow

partner = Partner(
    partner_type="Дилер",
    name="ООО Ромашка",
    director="Иванов Иван Иванович",
    phone="+7 223 322 22 32",
    rating=10,
    total_sales=62000,
)

window = PartnerListWindow(
    partners=[partner],
    partner_types=["Дилер", "Оптовик"],
)
window.run()
```

## Calculation helpers

```python
from pyqt6_templates import calculate_partner_discount, calculate_required_material

discount = calculate_partner_discount(62000)

material = calculate_required_material(
    product_type_id=1,
    material_type_id=2,
    product_count=10,
    parameter_1=2.5,
    parameter_2=3.0,
    product_type_coefficients={1: 1.2},
    material_defect_rates={2: 0.05},
)
```

## PyPI build

```bash
python -m pip install build twine
python -m build
python -m twine check dist/*
python -m twine upload dist/*
```

See `docs/PYPI_UPDATE.md` for version bump workflow.

## What's new in 0.3.0

- full shoe store app bundled: `pyqt6-shoe-store` command
- `form_helpers`: `open_form_window`, `close_form`, `check_role`, `confirm_delete`
- English hover docstrings on all main API
- `pyqt6_templates.apps.shoe_store` — complete reference application
