Skip to main content

A text-based UI system

Project description

# Python textui package
Text-based UI builder for Python

Full documentation provided at https://firsttempora.github.io/Python-textui/

## Quickstart

Install from `pip`: `pip install --user textui`

The `uielements` module contains individual `user_*` functions that can be
used to interactively get values:

```
from textui import uielements

>>> uielements.user_input_list('Choose your favorite fruit', ['Apple', 'Banana', 'Cherry'])
Choose your favorite fruit
A empty answer will cancel.
1: Apple 2: Banana 3: Cherry
Enter 1-3: 2
'Banana'

>>> uielements.user_input_date('When did the Eagle land on the moon?')
When did the Eagle land on the moon?
Enter in one of the formats: yyyy-mm-dd
Entering nothing will cancel
--> 1969-07-20
datetime.datetime(1969, 7, 20, 0, 0)
```

`uielements` also contains a series of `opt_user_*` functions that will decide if the
user needed to be queried based on the given value, or check is the value is valid:

```
# If the value None is given, it is assumed
# that the user need to provide a value
>>> uielements.opt_user_input_list('Choose your favorite fruit', None, ['Apple', 'Banana', 'Cherry'])
Choose your favorite fruit
A empty answer will cancel.
1: Apple 2: Banana 3: Cherry
Enter 1-3: 2
'Banana'

# If a non-None value is given, it is checked.
# So long as it is valid, it is returned.
>>> uielements.opt_user_input_list('Choose your favorite fruit', 'Apple', ['Apple', 'Banana', 'Cherry'])
'Apple'

# If not valid, an error is raised automatically
>>> uielements.opt_user_input_list('Choose your favorite fruit', 'Watermelon', ['Apple', 'Banana', 'Cherry'])
Error thrown using UIErrorWrapper
UIValueError: The value Watermelon is invalid. It must be one of: Apple, Banana, Cherry
```


Project details


Release history Release notifications | RSS feed

This version

0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textui-0.2.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

textui-0.2-py2.py3-none-any.whl (19.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file textui-0.2.tar.gz.

File metadata

  • Download URL: textui-0.2.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for textui-0.2.tar.gz
Algorithm Hash digest
SHA256 af8a647a6942f490f6118c5307739cbb01ee4f6de12a76946d23459b2d3d7d6d
MD5 63c107fdbc6f0e9aac357d9c6bc0793b
BLAKE2b-256 c3ac2b90ed9668515fa176f2b2f97d99d8a266deb92051b98c19aeda5219c05c

See more details on using hashes here.

File details

Details for the file textui-0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for textui-0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ed57c9b1309296c47d6a22fd3d273b84047d058fc470a5eea5474bd8689748d1
MD5 e19cdeb59cfca0f85630038e332fe222
BLAKE2b-256 7969e354defd17f3c24ae802c5694618618a2a8a72af77711a473483cc28a480

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page