Skip to main content

Template-based widgets and form helpers for PyQt6 applications

Project description

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 описывает внешний вид карточки;
  • FormTemplate и FormField описывают форму добавления/редактирования;
  • TemplateListWindow показывает список и открывает форму;
  • optional partner-management preset built on top of the template widgets;
  • small calculation helpers are included for demo business rules.

Installation

pip install -e .

Template Example

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()

The full example is available in examples/template_demo.py.

Shoe store demo (full assignment flow)

A complete demo with test data, login, roles, products, orders, search/filter/sort and CRUD without changing the library:

python examples/shoe_store_demo.py
python examples/shoe_store_exam.py

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

shoe_store_exam.py — полный экзаменационный билет на библиотеке v0.2+.

Partner Preset

If your application manages partners, you can use the built-in preset:

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

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

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 and update workflow.

What's new in 0.2.0

  • conditional card colors via CardStyleRule
  • image placeholder on cards (image_field)
  • decimal form fields for prices
  • TemplateListPage with search, filter, sort, delete
  • list helpers: search_items, filter_items, sort_items

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqt6_template_widgets-0.2.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyqt6_template_widgets-0.2.1-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file pyqt6_template_widgets-0.2.1.tar.gz.

File metadata

  • Download URL: pyqt6_template_widgets-0.2.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pyqt6_template_widgets-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ecc084fc0c316a140ea54ef557130bc596ac0a027110c6bf258e0fb2b09458e5
MD5 37798a38d513ed95cd3c797d89240bc1
BLAKE2b-256 68c62bd2e8bb8e317f9bb10dffc3e6e20bd972d2792db067a2aae112e17faf1f

See more details on using hashes here.

File details

Details for the file pyqt6_template_widgets-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyqt6_template_widgets-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6733d0be4534be10f6305ad8964eff5941950ae7535d8efa67f7701b7c7bd3d2
MD5 f1e527797828f56879dd5542b32af842
BLAKE2b-256 8523ada1f0c5031360b2d837f0c933eb1e9038f79c070319e692b62040557316

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page