Skip to main content

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 use curses, 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.2.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

getchoice-1.2.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file getchoice-1.2.0.tar.gz.

File metadata

  • Download URL: getchoice-1.2.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.10 Linux/6.2.8-arch1-1

File hashes

Hashes for getchoice-1.2.0.tar.gz
Algorithm Hash digest
SHA256 bad95e53a7c8fe2cbb2ebc5c9c2ab422c87112566879a41f8301bf66bfe8ea36
MD5 5449138a435e2f58aa26567fc4711ab9
BLAKE2b-256 55e50e6bfd5c663df01d5e7f725807d7dd450023fe378e49c4f5b43da137a588

See more details on using hashes here.

File details

Details for the file getchoice-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: getchoice-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.10 Linux/6.2.8-arch1-1

File hashes

Hashes for getchoice-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61354ecdfd6c2ed01d202a76eead42af4a3c338c4823d62db0c7518240a4e0a2
MD5 999b122489d9c289a5d437fc31b65ad0
BLAKE2b-256 3d3d8393f468625cb33b0877a29de88e69fae8acb54313afa8e52e4144c054e2

See more details on using hashes here.

Supported by

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