Skip to main content

pick an option in the terminal with a simple GUI

Project description

pick [![Build Status](https://travis-ci.org/wong2/pick.svg?branch=master)](https://travis-ci.org/wong2/pick)
====

**pick** is a small python library to help you create curses based interactive selection
list in the terminal. See it in action:

![Demo](example/basic.gif?raw=true)


### Installation

$ pip install pick

### Usage

**pick** comes with a simple api:

>>> from pick import pick

>>> title = 'Please choose your favorite programming language: '
>>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']
>>> option, index = pick(options, title)

#### Options

* `options`: a list of options to choose from
* `title`: (optional) a title above options list
* `indicator`: (optional) custom the selection indicator, defaults to *
* `default_index`: (optional) set this if the default selected option is not the first one

#### Register custom handlers

sometimes you may need to register custom handlers to specific keys, you can use the `register_custom_handler` API:

>>> from pick import Picker
>>> title, options = 'Title', ['Option1', 'Option2']
>>> picker = Picker(options, title)
>>> def go_back(picker):
... return None, -1
>>> picker.register_custom_handler(ord('h'), go_back)
>>> option, index = picker.start()

* the custom handler will be called with the `picker` instance as it's parameter.
* the custom handler should either return a two element tuple, or None.
* if None is returned, the picker would continue to run, otherwise the picker will stop and return the tuple.

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

pick-0.6.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

pick-0.6.0-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pick-0.6.0.tar.gz.

File metadata

  • Download URL: pick-0.6.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pick-0.6.0.tar.gz
Algorithm Hash digest
SHA256 90f380faea50c1b90b4a2033208dcd13b09714590c05657c9c55ea1f79c0acd0
MD5 b790e9c60bde0544c445ebe3f40411b2
BLAKE2b-256 73125a87a2b2de631e52c9dd27412261d2bd526608e1fa4925522f8d0f7392b3

See more details on using hashes here.

File details

Details for the file pick-0.6.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pick-0.6.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 875a5ad4c4738750142950466fdd2e57bf9dc32160ccf53a7f965cae4bc8759a
MD5 1d57c5d246c57ed93465ed5af6912e26
BLAKE2b-256 f4f9be1e6d67f05148cf08571a8b3fabffb2afcb093fdce78ba9a2e26ba1a293

See more details on using hashes here.

Supported by

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