No project description provided
Project description
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:
FieldValueException
RichFieldException
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.
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
File details
Details for the file rich_form-0.1.1.tar.gz
.
File metadata
- Download URL: rich_form-0.1.1.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0037826c75fba8e7f253fd3326fbeaa355ed9a31b0c1b39e3f38b130ca0d43ed |
|
MD5 | becb33ead448828809b5a4abb1e0fe32 |
|
BLAKE2b-256 | 0b1d483c13b63e26d4fb6eccb38d013e094a02ff75a2c91d10524f7de693b7a2 |
File details
Details for the file rich_form-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: rich_form-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Windows/11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12136b399834526854c4e459acf1c5db4f99196b8fb91dfb805956821f8b5857 |
|
MD5 | c6126c9a33678787950881aeaae21b54 |
|
BLAKE2b-256 | d9a5ed6fb3a169cd2267c8d2c7d660a3aa56ce88c741e33f5f47df3347043390 |