Skip to main content

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.

Release files for getchoice 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for getchoice 1.2.0
File Size Uploaded
getchoice-1.2.0.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for getchoice 1.2.0
File Interpreter ABI Platform
getchoice-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / getchoice-1.2.0.tar.gz

Download URL getchoice-1.2.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bad95e53a7c8fe2cbb2ebc5c9c2ab422c87112566879a41f8301bf66bfe8ea36
BLAKE2b-256 checksum
How to use checksums
55e50e6bfd5c663df01d5e7f725807d7dd450023fe378e49c4f5b43da137a588
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.10.10 Linux/6.2.8-arch1-1

Release files / getchoice-1.2.0-py3-none-any.whl

Download URL getchoice-1.2.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
61354ecdfd6c2ed01d202a76eead42af4a3c338c4823d62db0c7518240a4e0a2
BLAKE2b-256 checksum
How to use checksums
3d3d8393f468625cb33b0877a29de88e69fae8acb54313afa8e52e4144c054e2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.1 CPython/3.10.10 Linux/6.2.8-arch1-1

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page