Dynamic forms for Textual TUI Framework
Project description
Textual Forms
Dynamic forms for Textual TUI framework.
Note: This library is still very much WIP 🧪
Install
pip install textual-forms
Form Field Schema
Key | Type | Required | Options |
---|---|---|---|
id | string | X | |
type | string | string, number, integer, uuid | |
value | string, number | ||
required | boolean | ||
placeholder | string |
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...'
},
{
'id': 'age',
'type': 'integer',
'required': True,
'placeholder': 'age...'
},
{
'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 snippet, produces the following screen:
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.1.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for textual_forms-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a39a7e7f7f508c4c73209df86f10821d8ae2d455aacf70fab9eb3e559960c2b |
|
MD5 | 4c5100990a419af51ae9670f641c24a3 |
|
BLAKE2b-256 | c68eb27febc8c5dd985e4bb95fd8cea8889c45f873afb44d9a634dbf06e2d60c |