brayer
Turn a Pydantic model into a desktop form — declare the shape, get a validated object back.
You already described your data once, in types. brayer reads that description and
builds the dialog for you: one labelled widget per field, your defaults filled in,
your constraints enforced, and a validated model instance handed back on OK.
Quick example
import datetime
from pydantic import BaseModel
import brayer
class Person(BaseModel):
name: str
age: int
birthday: datetime.date
person = brayer.ask(Person) # a form appears
if person is not None:
print(person.name, person.age)
What it looks like
A slightly larger model, and the form it produces:
Nothing in that window was written by hand. The spin box range comes from
Field(ge=1, le=50), the two decimal places from decimal_places=2, the drop-down
entries from an Enum, the pre-filled tag from a default_factory, the type
selector from int | None, and the Edit Database… button from a nested
BaseModel.
Why "brayer"?
A brayer is the hand roller a printer uses to lay ink evenly across a forme before taking an impression. This library does the equivalent for a schema: it rolls your model out into a form, and what comes back is a clean impression of it.
What you get
- Validated results. The dialog will not close on OK until the values pass
model_validate; failures are shown per field. A non-Nonereturn is always a valid instance. - Cancel is distinguishable. Cancelling returns
None, never an empty dict that looks like a fieldless success. - Embeddable.
ModelDialogis a plainQDialog. It reuses an existingQApplication, so it works inside an app that already runs a Qt event loop — andask()can be called as many times as you like. - Extensible. A type it does not know about is one
@register_handleraway, with no edit to this package.
Supported types
Primitives, Decimal, bytes, dates and times, timedelta, UUID, Path,
IP addresses, Enum (including IntEnum and auto()), Literal, list, set,
frozenset, tuple, dict, Optional, unions in both spellings, Annotated,
and nested BaseModels — composed to any depth.
Field(...) constraints reach the widgets: ge/gt/le/lt set spin box
ranges, max_length caps line edits, decimal_places sets precision,
title and description become the label and tooltip, and default /
default_factory pre-fill the form.
See the full table.
Installation
pip install brayer
Requires Python 3.10+. On a bare Linux container you may also need Qt's runtime libraries — see the installation guide for that, and for uv, poetry, pdm and source builds.
Documentation
- Quickstart — runnable examples, flat models through to nested ones
- Supported types — every annotation that maps to a widget
- How it works — the dispatch and handler architecture, and how to add a type
- API reference — the full public surface
Contributing
The test suite runs headlessly, so no display is needed:
git clone https://github.com/eggzec/brayer.git
cd brayer
uv sync
uv run pytest
uv run ruff check . && uv run ruff format --diff .
Brand assets and the documentation screenshot are generated, not committed by
hand — uv run python tools/make_assets.py and
uv run python tools/make_screenshot.py regenerate them.
License
GNU General Public License v3 or later — see LICENSE.
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 brayer-0.1.2.tar.gz.
File metadata
- Download URL: brayer-0.1.2.tar.gz
- Upload date:
- Size: 128.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9ab112e8d6970f1adb710f47fc0929a0e41fd3dbcd41df2c3cecd6e2e49e3f7
|
|
| MD5 |
54d68c7ba28ffb840e58f95f8cdc36a1
|
|
| BLAKE2b-256 |
f6685cd0150793f85fc5f8d5991e332404db50d3e5306bdf33c3da21fd659127
|
Provenance
The following attestation bundles were made for brayer-0.1.2.tar.gz:
Publisher:
publish_dist.yml on eggzec/brayer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brayer-0.1.2.tar.gz -
Subject digest:
c9ab112e8d6970f1adb710f47fc0929a0e41fd3dbcd41df2c3cecd6e2e49e3f7 - Sigstore transparency entry: 2583283613
- Sigstore integration time:
-
Permalink:
eggzec/brayer@3b9cac21620cddc741a9eef12562bd7ade51865e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/eggzec
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_dist.yml@3b9cac21620cddc741a9eef12562bd7ade51865e -
Trigger Event:
release
-
Statement type:
File details
Details for the file brayer-0.1.2-py3-none-any.whl.
File metadata
- Download URL: brayer-0.1.2-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea0e980cf5205ce33ca6a80a866ab8a5d3553f59e0edeaa6a183c2c79c031be3
|
|
| MD5 |
9f9f38c8d82688691c672cec5895012b
|
|
| BLAKE2b-256 |
67b3fc1682ecdf1d0079b6fc7687aa417d7dcfff4b2fe869fdf121624b4b6189
|
Provenance
The following attestation bundles were made for brayer-0.1.2-py3-none-any.whl:
Publisher:
publish_dist.yml on eggzec/brayer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brayer-0.1.2-py3-none-any.whl -
Subject digest:
ea0e980cf5205ce33ca6a80a866ab8a5d3553f59e0edeaa6a183c2c79c031be3 - Sigstore transparency entry: 2583283647
- Sigstore integration time:
-
Permalink:
eggzec/brayer@3b9cac21620cddc741a9eef12562bd7ade51865e -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/eggzec
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_dist.yml@3b9cac21620cddc741a9eef12562bd7ade51865e -
Trigger Event:
release
-
Statement type: