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.

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 upload dist/*

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.1.0.tar.gz (11.9 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.1.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyqt6_template_widgets-0.1.0.tar.gz
  • Upload date:
  • Size: 11.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 636c7823ef0727da33c8753fbab475af334c365bfe11b505fc5bbf72200ed062
MD5 ba5c3dcf61b8e2ae25d290512e1b8be3
BLAKE2b-256 6bd9ae3905666d3c16891845f78786dc42b88cca1e80416b63174d1306ab6844

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyqt6_template_widgets-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7cef4a27ac70d6997b831b6e2f1dd54363e4445a6e4c74c4133a633b7611395d
MD5 b0db34b76efcb6a0d84a46b206bd9197
BLAKE2b-256 ce17fe3a819ea4cab3b3908b5407fb9c96e72c908e776257089fc5bda047f7b7

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