Metadata-Version: 2.1
Name: textual-forms
Version: 0.1.1
Summary: Dynamic forms for Textual TUI Framework
Home-page: https://github.com/rhymiz/textual-forms
License: MIT
Keywords: tui,terminal,form,widget
Author: Lemuel Boyce
Author-email: lemuelboyce@gmail.com
Requires-Python: >=3.7,<4.0
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: textual[dev] (>=0.4.0,<0.5.0)
Project-URL: Repository, https://github.com/rhymiz/textual-forms
Description-Content-Type: text/markdown

# Textual Forms

[![Python Versions](https://shields.io/pypi/pyversions/textual-inputs)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

Dynamic forms for [Textual](https://github.com/willmcgugan/textual) TUI framework.

> #### Note: This library is still very much WIP 🧪

## Install

```bash
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

```python
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:

<img width="1006" alt="Screenshot 2022-11-12 at 12 51 53 AM" src="https://user-images.githubusercontent.com/7029352/201459554-df7f605b-62cd-4160-80e9-32d6deac9739.png">

