{ "info": { "author": "jaitaiwan", "author_email": "dan@djcentric.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3.6" ], "description": "pick [![Build Status](https://travis-ci.org/wong2/pick.svg?branch=master)](https://travis-ci.org/wong2/pick) [![PyPI](https://img.shields.io/pypi/v/pick.svg)](https://pypi.python.org/pypi/pick)\n====\n\n**pick** is a small python library to help you create curses based interactive selection\nlist in the terminal. See it in action:\n\n![Demo](example/basic.gif?raw=true)\n\n\n### Installation\n\n $ pip install pick\n\n### Usage\n\n**pick** comes with a simple api:\n\n >>> from pick import pick\n\n >>> title = 'Please choose your favorite programming language: '\n >>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']\n >>> option, index = pick(options, title)\n >>> print option\n >>> print index\n\n**outputs**\n\n >>> C++\n >>> 4\n\n**pick** multiselect example:\n\n >>> from pick import pick\n\n >>> title = 'Please choose your favorite programming language (press SPACE to mark, ENTER to continue): '\n >>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']\n >>> selected = pick(options, title, multi_select=True, min_selection_count=1)\n >>> print selected\n\n**outputs**\n\n >>> [('Java', 0), ('C++', 4)]\n\n\n#### Options\n\n* `options`: a list of options to choose from\n* `title`: (optional) a title above options list\n* `indicator`: (optional) custom the selection indicator, defaults to *\n* `default_index`: (optional) set this if the default selected option is not the first one\n* `multi_select`: (optional), if set to True its possible to select multiple items by hitting SPACE\n* `min_selection_count`: (optional) for multi select feature to dictate a minimum of selected items before continuing\n* `options_map`: (optional) a mapping function to pass each option through before displaying\n* `multi_select_foreground_color`: (optional) forground color of a selected option within multi_select mode\n* `multi_select_background_color`: (optional) background color of a selected option within multi_select mode\n\n#### Register custom handlers\n\nsometimes you may need to register custom handlers for specific keyboard keys, you can use the `register_custom_handler` API:\n\n >>> from pick import Picker\n >>> title, options = 'Title', ['Option1', 'Option2']\n >>> picker = Picker(options, title)\n >>> def go_back(picker):\n ... return None, -1\n >>> picker.register_custom_handler(ord('h'), go_back)\n >>> option, index = picker.start()\n\n* the custom handler will be called with the `picker` instance as it's parameter.\n* the custom handler should either return a two element tuple, or None.\n* if None is returned, the picker would continue to run, otherwise the picker will stop and return the tuple.\n\n#### Options Map\n\nIf your options are not in a format that you want displayed (such as a dictionary), you can pass in a mapping function which each option will be run through. The return value of the function will be displayed.\n\n* the selected option returned will be the original value and not the displayed return result from the `options_map` function.\n\n**pick** options map example:\n\n >>> from pick import pick\n\n >>> title = 'Please choose an option: '\n >>> options = [{'label': 'option1'}, {'label': 'option2'}, {'label': 'option3'}]\n\n >>> def get_label(option): return option.get('label')\n\n >>> selected = pick(options, title, indicator='*', options_map=get_label)\n >>> print selected\n\n**displays**\n\n Please choose an option:\n\n * option1\n option2\n option3\n\n**outputs**\n\n >>> ({ 'label': 'option1' }, 0)\n\n### Multi-Select Colors\n\nUsing the `multi_select_foreground_color` and `multi_select_background_color` options, you can specify the colors that are used when a user selects an option as part of the multi-select mode.\n\nThe accepted colors are any of the [curses](https://docs.python.org/2/library/curses.html) predefined color constants, passed as a string:\n```\n'COLOR_BLACK'\n'COLOR_BLUE'\n'COLOR_CYAN'\n'COLOR_GREEN'\n'COLOR_MAGENTA'\n'COLOR_RED'\n'COLOR_WHITE'\n'COLOR_YELLOW'\n```\n\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/wong2/pick", "keywords": "terminal gui", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pick2", "package_url": "https://pypi.org/project/pick2/", "platform": "", "project_url": "https://pypi.org/project/pick2/", "project_urls": { "Homepage": "https://github.com/wong2/pick" }, "release_url": "https://pypi.org/project/pick2/0.7.1/", "requires_dist": null, "requires_python": "", "summary": "pick an option in the terminal with a simple GUI", "version": "0.7.1" }, "last_serial": 3500901, "releases": { "0.7.1": [ { "comment_text": "", "digests": { "md5": "70757520668d390180a4b1a875c17b44", "sha256": "27416d00dae1ae30351ec31cf9f37d3810c2480fbaf434b04c2ebf8f6bb4cf7e" }, "downloads": -1, "filename": "pick2-0.7.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "70757520668d390180a4b1a875c17b44", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7419, "upload_time": "2018-01-18T13:55:36", "url": "https://files.pythonhosted.org/packages/34/91/1d635951e127808922d424cf98c54da975cb8ae5c414d0631071dc290329/pick2-0.7.1-py2.py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "70757520668d390180a4b1a875c17b44", "sha256": "27416d00dae1ae30351ec31cf9f37d3810c2480fbaf434b04c2ebf8f6bb4cf7e" }, "downloads": -1, "filename": "pick2-0.7.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "70757520668d390180a4b1a875c17b44", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7419, "upload_time": "2018-01-18T13:55:36", "url": "https://files.pythonhosted.org/packages/34/91/1d635951e127808922d424cf98c54da975cb8ae5c414d0631071dc290329/pick2-0.7.1-py2.py3-none-any.whl" } ] }