Dynamic forms for Textual TUI Framework
Project description
Textual Forms
Dynamic forms for Textual TUI framework.
Note: This library is still very much WIP 🧪
About
Textual Forms aims to make it easy to add forms to your Textual-powered applications.
Install
pip install textual-forms
Form Field Schema
Key | Type | Required | Options |
---|---|---|---|
id | str | X | |
type | str | string, number, integer | |
value | str, number | ||
required | bool | ||
placeholder | str | ||
rules | dict |
Type Rules
string
- min_length
- max_length
integer
- min
- max
number
- N/A
Example
from rich.table import Table
from textual.app import App, ComposeResult
from textual.widgets import Static
from textual_forms.forms import TextualForm
FORM_DATA = [
{
'id': 'name',
'required': True,
'placeholder': 'name...',
'rules': {
'min_length': 3,
}
},
{
'id': 'age',
'type': 'integer',
'required': True,
'placeholder': 'age...',
'rules': {
'min': 18,
'max': 65
}
},
{
'id': 'email',
'required': False,
'placeholder': 'hi@example.com',
},
]
class BasicTextualForm(App):
def compose(self) -> ComposeResult:
yield Static(id='submitted-data')
yield TextualForm(FORM_DATA)
def on_textual_form_submit(self, message: TextualForm.Submit) -> None:
table = Table(*message.data.keys())
table.add_row(*message.data.values())
self.query_one('#submitted-data').update(table)
if __name__ == '__main__':
BasicTextualForm().run()
The above form data produces the below form
Contributing
TBD
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
textual_forms-0.1.2.tar.gz
(5.0 kB
view hashes)
Built Distribution
Close
Hashes for textual_forms-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 999b7f60092a3f925dc6c1c55ec9e7596c8963fae03086436783da87b0f0e43b |
|
MD5 | f4b74ba6958a6c70221abc475248919f |
|
BLAKE2b-256 | ae0f1e303cd69b267145b3a7e2ce3bcc67868a298f767f219a860959cc2dd364 |