Simple, extensible user selection interface for CLI applications
Project description
getchoice
A simple library to allow a user to select from a list of options on the command line. Like pick, but with two major differences:
getchoice
is intended for use alongside python prompt toolkit; its output can be styled using PPT-style(styling, text)
format.getchoice
does not usecurses
, and does not clear the screen when used.
Install it from PyPI: pip install getchoice
from getchoice import ChoicePrinter
from datetime import date
choice_printer = ChoicePrinter(normal_style="green italic")
items = [
("February 1", date(2023, 2, 1)),
("Pi Day", date(2023, 3, 14)),
("Stanislav Petrov Day", date(2023, 9, 26))
]
choice_printer.getchoice(items, title = "Select a date")
This displays an interactive prompt menu for the choices, that the user can navigate with the arrow or j/k keys, and select and item with space or enter. choice_printer.getchoice()
returns a tuple of the form (selected_index: int, selected_object)
For further details, see the getchoice/getchoice.py
file; it's quite simple and hopefully unsuprising.
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
getchoice-1.1.0.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for getchoice-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80838bcc5ed0dd2a150d458c367f16d574b082f04a768ef718be29b4a466e5b3 |
|
MD5 | a6741bb0d23dd0eb2c141fe2944e3054 |
|
BLAKE2b-256 | 78292560dfc49c61d12ac94fb0f728e9b72e627f6ffd42d74eaa1660112ec618 |