Skip to main content

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


Download files

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

Source Distribution

fastqt6-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

fastqt6-0.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

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

Hashes for fastqt6-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8879269ab7c9104d27b560ad6f551396e2563bb7cce70e4c6b546eec01a0a047
MD5 6c013cfb414a886a62ad6b163d06d40c
BLAKE2b-256 66ea25939dea86b90eea41ee7af3757604f52a55996e7e6089252290070b21f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastqt6-0.1.0.tar.gz:

Publisher: publish.yml on Leevandr/fastQT6

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for fastqt6-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8cf04b81a8dd3ea6c5c008e11547caf09d7013eb66977bf4e51fc5494a71791
MD5 af8e6ff8a97b9a67456c6f681d7074b6
BLAKE2b-256 e7ce5e1b13b13756077f16c4ab4bfb840ec8e9eca1961736603229ed7364eaee

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastqt6-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Leevandr/fastQT6

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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