Interactive list selection and multiselect for POSIX terminals (non-curses)
Reason this release was yanked:
buggy
Project description
python-listpicker
Interactive list selection for POSIX terminals.
pip install listpicker
Python 3.10+
Features
- Single and multiple selection from a sequence of strings
- Interactive substring filtering
- Paging for long lists
- Common navigation keybindings (vi, emacs, arrow keys, Home/End, etc)
- Direct terminal manipulation with CSI commands (i.e. no curses)
- Draw to main screen buffer without clearing the screen
- Proper truncation of long lines with SGR color sequences
- Redraw on terminal resize (SIGWINCH)
- Help menu and multiselect confirmation prompt
- Preselected options in multiselect prompts
Screenshots
Examples
Basic usage
import listpicker
pizza_styles = ("Thin crust", "Stuffed crust", "Deep dish")
style = listpicker.pick("Choose pizza style:", pizza_styles)
# User can abort input, so handle the case where "pick()" returns "None"
if style is None:
style = pizza_styles[0]
pizza_toppings = ("Pepperoni", "Sausage", "Mushroom", "Pineapple")
toppings = listpicker.pick_multiple("Choose toppings:", pizza_toppings)
Typical usage with dictionary
import dataclasses
import listpicker
@dataclasses.dataclass
class Book:
isbn: str
title: str
authors: list[str]
publication_year: int
books = [
Book(
"0201038013",
"The Art of Computer Programming, Volume 1: Fundamental Algorithms",
["Knuth, Donald"],
1968,
),
Book(
"0262010771",
"Structure and Interpretation of Computer Programs",
["Harold Abelson", "Gerald Jay Sussman", "Julie Sussman"],
1984,
),
Book(
"032163537X",
"Elements of Programming",
["Stepanov, Alexander A.", "McJones, Paul"],
2009,
),
]
options = {f"{b.title} ({b.publication_year})": b for b in books}
choice = listpicker.pick("Pick a book:", list(options.keys()))
# Pick a book:
# (filter with f, submit with Enter, F1 for keybindings)
# > 1. The Art of Computer Programming, Volume 1: Fundamental Algorithms (1968)
# 2. Structure and Interpretation of Computer Programs (1984)
# 3. Elements of Programming (2009)
if choice:
book = options[choice]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
listpicker-0.3.4.tar.gz
(11.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file listpicker-0.3.4.tar.gz.
File metadata
- Download URL: listpicker-0.3.4.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3d050fb762585ac957c899b5d7bff2aa8488c9955ab43adcea6125c56fb7dda
|
|
| MD5 |
bb3279dfa3bd0ae5c6e7bcc30a62f3bc
|
|
| BLAKE2b-256 |
4c936bee1fb7ba6bdbf36c4795463feae57541275a0f29ef1a631e6afc595e25
|
File details
Details for the file listpicker-0.3.4-py3-none-any.whl.
File metadata
- Download URL: listpicker-0.3.4-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5de6dd08ae92e4c0e95be1a7dea183293d2de3ae45e09e29eb70f2ec6ea160b3
|
|
| MD5 |
957e16365a98a196906a87ce1924250c
|
|
| BLAKE2b-256 |
045cde22b2534183a2a0a7718f7ab41d598905f4e66c2f343696f68039faf159
|