Rich Form Library
Motivation
The Rich Form library was created to provide an easy and visually appealing way to render and interact with forms in the terminal using the Rich library. The idea for creating this library came after reading this discussion
Installation
To install the Rich Form library, you can use pip:
pip install rich-form
Usage
Basic Example
Here's a basic example to get you started with the Rich Form library:
from rich.console import Console
from rich_form import Form, BoolField, LiteralField
@dataclass
class Example:
accept_terms: bool = BoolField(field_name='any name', current=True, aliases=("Yes", "No"))
favorite_color: str = LiteralField(values=('blue', 'magneta', 'pinky'), field_name='favorite color')
# Initialize the form
example = Example()
form = Form(example)
# Create a console and print the form
console = Console()
console.print(form)
Styling
The Rich Form library allows you to customize the appearance of your forms using styles. You can define styles for different parts of the form:
from rich_form import Form
from rich.style import Style
from rich_form import PanelStyle
selected_style = Style(color="black", bold=True, bgcolor="green")
panel_style = PanelStyle(title="[bold green]Data", border_style="green")
form = Form(example, panel_style=panel_style, selected_style=selected_style)
Components
Fields
BoolField: A field for boolean values.LiteralField: A field for literal (string) values.
Form
The Form class is the main component of the Rich Form library. It is used to render and manage the form:
from rich_form import Form
form = Form(dataclass_instance)
Exceptions
The library defines the following exceptions for error handling:
FieldValueExceptionRichFieldException
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue on GitHub.
License
This project is licensed under the MIT License.
Metadata
Release files for rich-form 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| rich_form-0.1.1.tar.gz | 10.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rich_form-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.1 kB
Release files / rich_form-0.1.1.tar.gz
| Download URL | rich_form-0.1.1.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0037826c75fba8e7f253fd3326fbeaa355ed9a31b0c1b39e3f38b130ca0d43ed
|
|
BLAKE2b-256 checksum How to use checksums |
0b1d483c13b63e26d4fb6eccb38d013e094a02ff75a2c91d10524f7de693b7a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Windows/11
|
Release files / rich_form-0.1.1-py3-none-any.whl
| Download URL | rich_form-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
12136b399834526854c4e459acf1c5db4f99196b8fb91dfb805956821f8b5857
|
|
BLAKE2b-256 checksum How to use checksums |
d9a5ed6fb3a169cd2267c8d2c7d660a3aa56ce88c741e33f5f47df3347043390
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Windows/11
|
Security for rich-form 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.