Convenient PyQt6 templates for dynamic forms, CRUD windows, Designer .ui files and SQL helpers
Project description
fastqt6
fastqt6 - это небольшая библиотека-шаблон для PyQt6-проектов: динамические формы,
CRUD-окна, SQL-хелперы и генерация .ui файлов для Qt Designer.
Установка после публикации:
pip install fastqt6
Локальная установка из репозитория:
python -m pip install -e .
Быстрый пример
from PyQt6.QtWidgets import QApplication
from fastqt6 import SQLDatabase, field
from fastqt6.widgets import CrudWindow
SCHEMA = """
create table if not exists products (
id integer primary key autoincrement,
article text not null,
title text not null,
price real not null default 0,
stock integer not null default 0
);
"""
app = QApplication([])
db = SQLDatabase.sqlite("app.db")
db.run_script(SCHEMA)
window = CrudWindow(
db,
table="products",
fields=[
field("article", "Артикул", required=True),
field("title", "Название", required=True),
field("price", "Цена", "float", min_value=0),
field("stock", "Остаток", "int", min_value=0),
],
)
window.show()
app.exec()
SQL-хелперы
SQLite:
from fastqt6 import SQLDatabase
db = SQLDatabase.sqlite("app.db")
db.insert("products", {"article": "A-1", "title": "Мяч", "price": 1000})
rows = db.select("products", where="price > ?", params=(500,), order_by="title")
db.update("products", {"price": 1200}, "id=?", (1,))
db.delete("products", "id=?", (1,))
MySQL:
from fastqt6 import SQLDatabase
db = SQLDatabase.mysql("sportplus_kvalik", user="root", password="")
user = db.login("users", "admin", "admin")
rows = db.fetch_all("select * from products where title like ?", ("%мяч%",))
В запросах можно писать ? как универсальный placeholder. Для MySQL библиотека
сама заменит его на %s.
Динамические формы
from fastqt6 import field
from fastqt6.forms import DynamicFormDialog
fields = [
field("article", "Артикул", required=True),
field("title", "Название", required=True),
field("price", "Цена", "float", min_value=0),
field("category_id", "Категория", "combo", choices=[("Мячи", 1), ("Обувь", 2)]),
]
dialog = DynamicFormDialog(fields, title="Товар")
if dialog.exec():
data = dialog.get_data()
Генерация файлов Qt Designer
Создать auth.ui:
fastqt6 ui-auth ui/auth.ui
Создать главное окно с вкладками:
fastqt6 ui-main ui/main.ui --tabs "Каталог,Мои заказы,Все заказы,Статистика"
Создать форму:
fastqt6 ui-form ui/product.ui \
--title "Товар" \
--class-name "ProductDialog" \
--field article:text:Артикул \
--field title:text:Название \
--field price:float:Цена \
--field stock:int:Остаток
После этого файл можно открыть в Qt Designer или конвертировать:
pyuic6 ui/product.ui -o gen/product.py
CLI
fastqt6 scaffold my_app
fastqt6 ui-auth ui/auth.ui
fastqt6 ui-main ui/main.ui
fastqt6 ui-form ui/form.ui --field title:text:Название
Что вводить на PyPI Trusted Publisher
Для репозитория git@github.com:Leevandr/fastQT6.git заполни форму так:
PyPI Project Name: fastqt6
Owner: Leevandr
Repository name: fastQT6
Workflow name: publish.yml
Environment name: pypi
Workflow уже лежит в .github/workflows/publish.yml. В GitHub желательно создать
environment с названием pypi: Settings -> Environments -> New environment.
Публикация пойдет через GitHub Actions без API-токена: после настройки Trusted Publisher создай GitHub Release или запусти workflow вручную.
Project details
Release history Release notifications | RSS feed
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 fastqt6-0.1.0.tar.gz.
File metadata
- Download URL: fastqt6-0.1.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8879269ab7c9104d27b560ad6f551396e2563bb7cce70e4c6b546eec01a0a047
|
|
| MD5 |
6c013cfb414a886a62ad6b163d06d40c
|
|
| BLAKE2b-256 |
66ea25939dea86b90eea41ee7af3757604f52a55996e7e6089252290070b21f5
|
Provenance
The following attestation bundles were made for fastqt6-0.1.0.tar.gz:
Publisher:
publish.yml on Leevandr/fastQT6
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastqt6-0.1.0.tar.gz -
Subject digest:
8879269ab7c9104d27b560ad6f551396e2563bb7cce70e4c6b546eec01a0a047 - Sigstore transparency entry: 1586523616
- Sigstore integration time:
-
Permalink:
Leevandr/fastQT6@77fb0dc9c100a47e0698b5461ab5ab74130f1f3c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Leevandr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@77fb0dc9c100a47e0698b5461ab5ab74130f1f3c -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file fastqt6-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fastqt6-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8cf04b81a8dd3ea6c5c008e11547caf09d7013eb66977bf4e51fc5494a71791
|
|
| MD5 |
af8e6ff8a97b9a67456c6f681d7074b6
|
|
| BLAKE2b-256 |
e7ce5e1b13b13756077f16c4ab4bfb840ec8e9eca1961736603229ed7364eaee
|
Provenance
The following attestation bundles were made for fastqt6-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Leevandr/fastQT6
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastqt6-0.1.0-py3-none-any.whl -
Subject digest:
a8cf04b81a8dd3ea6c5c008e11547caf09d7013eb66977bf4e51fc5494a71791 - Sigstore transparency entry: 1586523637
- Sigstore integration time:
-
Permalink:
Leevandr/fastQT6@77fb0dc9c100a47e0698b5461ab5ab74130f1f3c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Leevandr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@77fb0dc9c100a47e0698b5461ab5ab74130f1f3c -
Trigger Event:
workflow_dispatch
-
Statement type: