Skip to content
プロジェクト

概要

cursesベースの対話型選択リストをターミナル上に作成します。

開発ツール

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
0
1か月
+1

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

pick

image PyPI PyPI Python 3.10 - 3.14 support

pick is a small python library to help you create interactive selection list in the terminal.

Basic Multiselect

Installation

$ pip install pick

Optional: blessed backend

pick uses the curses backend by default. If you prefer using blessed, install the optional extra:

$ pip install "pick[blessed]"

Then pass backend="blessed" to pick(...).

Usage

pick comes with a simple api:

>>> import pick
>>> # You can also use `from pick import pick` if you do not want to use cadule's magic: https://github.com/aisk/cadule

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

outputs:

>>> C++
>>> 4

pick multiselect example:

>>> from pick import pick

>>> title = 'Please choose your favorite programming language (press SPACE to mark, ENTER to continue): '
>>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']
>>> selected = pick(options, title, multiselect=True, min_selection_count=1)
>>> print(selected)

outputs:

>>> [('Java', 0), ('C++', 4)]

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
  • multiselect: (optional), if set to True its possible to select multiple items by hitting SPACE
  • min_selection_count: (optional) for multi select feature to dictate a minimum of selected items before continuing
  • screen: (optional), if you are using pick within an existing curses application set this to your existing screen object. It is assumed this has initialised in the standard way (e.g. via curses.wrapper(), or curses.noecho(); curses.cbreak(); screen.kepad(True))
  • position: (optional), if you are using pick within an existing curses application use this to set the first position to write to. e.g., position=pick.Position(y=1, x=1)
  • quit_keys: (optional), if you want to quit early, you can pass a key codes. If the corresponding key are pressed, it will quit the menu.
  • backend: (optional), the rendering backend to use. Accepts "curses" (default), "blessed" (requires pip install pick[blessed]), or a custom Backend instance.

Community Projects

pickpack: A fork of pick to select tree data.

関連プロジェクトを探す

読み込み中…