Textual Forms
Dynamic forms for Textual TUI framework.
Note: This library is still very much WIP 🧪. This means that breaking changes can be introduced at any point in time.
About
Textual Forms aims to make it easy to add forms to your Textual-powered applications.
Development Requirements
- python >=3.7,<4
- poetry
- textual >=0.11.0
Install
pip install textual-forms
Forms
textual_forms.forms.Form
Buttons
textual_forms.buttons.Button
Fields
textual_forms.fields.StringField
textual_forms.fields.NumberField
textual_forms.fields.IntegerField
Custom fields and validators
from __future__ import annotations
from typing import Any
from textual_forms.fields import Field
from textual_forms.validators import FieldValidator
class UUIDValidator(FieldValidator):
def validate(self, value: str, rules: dict[str, Any]) -> tuple[bool, str | None]:
return True, None
class UUIDField(Field):
validator = UUIDValidator()
def __init__(
self,
name: str,
*,
value: str | None = None,
required: bool = False,
placeholder: str | None = None,
**kwargs,
):
data: dict[str, Any] = {
"name": name,
"value": value,
"required": required,
"placeholder": placeholder,
"rules": {},
}
super().__init__(data, **kwargs)
Example
from rich.table import Table
from textual.app import App, ComposeResult
from textual.widgets import Static
from textual_forms.forms import Form
from textual_forms.fields import StringField, IntegerField
from textual_forms.buttons import Button
class BasicTextualForm(App):
def compose(self) -> ComposeResult:
yield Static(id="submitted-data")
yield Static("Order for beers")
yield Form(
fields=[
StringField("name"),
IntegerField("age", required=True, min_value=21),
],
buttons=[
Button(
"Submit",
enabled_on_form_valid=True,
)
],
)
def on_form_event(self, message: Form.Event) -> None:
if message.event == 'submit':
table = Table(*message.data.keys())
table.add_row(*message.data.values())
self.query_one('#submitted-data').update(table)
if __name__ == '__main__':
BasicTextualForm().run()
Initial render
Valid form
Invalid form
Contributing
TBD
Metadata
Release files for textual-forms 0.3.0
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 | Actions |
|---|---|---|---|---|
| textual_forms-0.3.0.tar.gz | 7.2 kB | Without provenance | Details for textual_forms-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| textual_forms-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for textual_forms-0.3.0-py3-none-any.whl |
Total release size: 15.2 kB
Release files / textual_forms-0.3.0.tar.gz
| Download URL | textual_forms-0.3.0.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d41b884c69cb0042a0cf6835338435435811e6dc06cfd7c0a44a766dbddf54f3
|
|
BLAKE2b-256 checksum How to use checksums |
1a62846ac6b2082291a8debb05bf0c86343a5929c8b28076d4e98c70db0c3351
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.7.15 Linux/5.15.0-1033-azure
|
Release files / textual_forms-0.3.0-py3-none-any.whl
| Download URL | textual_forms-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b886d38497d2d34f71fefa17ada5d44e54f13ea20b80bb328c9919ebc77da8f
|
|
BLAKE2b-256 checksum How to use checksums |
18f8454a0b6a0d12c22917933528d003247f062093ea414ceb79849934ce2787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.7.15 Linux/5.15.0-1033-azure
|
Security for textual-forms 0.3.0
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.