Pick

2.6.0 · active · verified Tue Apr 14

Pick is a small Python library that simplifies creating interactive selection lists in the terminal. It provides a straightforward API for single and multi-select menus, making it easy to build command-line interfaces. The library is currently at version 2.6.0 and maintains an active, though not rapid, release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates both single and multi-selection using the `pick` function. For multi-selection, users can navigate with arrow keys, select/deselect with SPACE, and finalize their choices with ENTER. The `min_selection_count` ensures a minimum number of items are selected before proceeding.

from pick import pick

# Single selection example
title = 'Please choose your favorite programming language: '
options = ['Python', 'JavaScript', 'C/C++', 'Java', 'Rust']
selected, index = pick(options, title)
print(f"You picked {selected} at index {index}")

# Multi-selection example
title_multiselect = 'Please choose all languages you like (press SPACE to select, ENTER to finish): '
min_selection = 1 # User must select at least 1 item
selected_multi, indices_multi = pick(options, title_multiselect, multiselect=True, min_selection_count=min_selection)
print(f"You picked {selected_multi} at indices {indices_multi}")

view raw JSON →