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
Test accounts: client1/123, manager1/123, admin1/123, or guest login.
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
TemplateListPagewith 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyqt6_template_widgets-0.2.0.tar.gz.
File metadata
- Download URL: pyqt6_template_widgets-0.2.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf24aa866913d33b4ee9e8491af5ba9f8fa3c62764775813c23c6be96960bcb6
|
|
| MD5 |
2bf8d3fd92ccb0a79b6601a282a95e1a
|
|
| BLAKE2b-256 |
ada71fee5c86e8e23b044e6e6336e255bafa7b3074be5dad517e7f311190aeeb
|
File details
Details for the file pyqt6_template_widgets-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyqt6_template_widgets-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c69d094f3aac231916d7116c9f112def64ed54a51176c2c69f4ca55a2353e051
|
|
| MD5 |
1d181a00d9cecb519e6864871a858d75
|
|
| BLAKE2b-256 |
6977e222f58e326ae5d73edf7b76ae87ca29910c44b9ce467e63e50f2e39af6c
|