A reusable curses component library for terminal UI (TUI) applications.
Project description
curses_components
A reusable Python terminal UI library built on curses. Provides a grid viewer for tabular data and a vi-like text editor popup. Both components focus purely on the user interface and accept data in a canonical format.
Components
GridComponent Displays tabular data (e.g. CSV, database result sets) in a scrollable, interactive grid. Supports filtering, sorting, searching, column navigation, and CSV export.
EditorPopup A vi-like modal text editor shown as a popup window. Suitable for editing small text files such as SQL scripts. Supports insert mode, normal mode commands, search, substitute, and sort.
ScrollablePopup Base class for bordered, scrollable popup windows. Subclass to build custom help screens or information panels.
Installation
Install as an editable local package (recommended for development):
pip install -e /path/to/curses_component
Or add as a git submodule in another project:
git submodule add <repo-url> libs/curses_component
pip install -e libs/curses_component
Usage
GridComponent:
import curses
from curses_components import GridComponent
data = [
{'name': 'Alice', 'age': 30},
{'name': 'Bob', 'age': 25},
]
def main(stdscr):
grid = GridComponent(data, fg_color='green', bg_color='black')
grid.display(stdscr)
curses.wrapper(main)
EditorPopup:
import curses
from curses_components import EditorPopup
def main(stdscr):
editor = EditorPopup(stdscr, title='Edit', fg_color='green',
bg_color='black', bold=True)
result = editor.edit(text='', filename='script.sql')
if result is not None:
print(result)
curses.wrapper(main)
See examples/ for runnable demos:
python examples/grid_editor.py
python examples/text_editor.py
python examples/text_editor.py <file>
python examples/text_editor.py --size 120x40 <file>
GridComponent key bindings
Navigation: j/k/h/l or arrow keys, Home/End, Page Up/Down, ^/$ Search: / (substring), r/
EditorPopup key bindings
Normal mode: h/j/k/l or arrow keys, w/b (word), 0/$ (line), gg/G (file) Editing: i/a (insert), o/O (new line), x (delete char), dw (delete word), dd (delete line), yy (yank), p (paste), u (undo) Search: / (enter), n/N (next/previous) Command mode: :w [file], :q, :q!, :wq, :x, : (jump to line) Substitute: :s/pat/rep[/g], :%s/pat/rep[/g] Sort: :sort[!][ u] Help: :help
Color options (both components)
Both GridComponent and EditorPopup accept fg_color, bg_color, and border_color as constructor arguments. Valid color names:
black blue cyan green magenta red white yellow
EditorPopup also accepts bold=True (bright text) and bold_background=True.
Dependencies
- Python 3.13+
- pyperclip (for copy/copyrow commands in GridComponent)
License
MIT
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
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 curses_components-26.7.2.tar.gz.
File metadata
- Download URL: curses_components-26.7.2.tar.gz
- Upload date:
- Size: 22.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b10bc4fe8ead12beccca7ef4616600bdc68e78ce21ad8e7a008d5f3a735269f
|
|
| MD5 |
83d975d4c7070355e86dbca1e42f27a3
|
|
| BLAKE2b-256 |
11ae327ed734e296fcbe26dac6a71ab516318a107bc9fc524f084ac60d6edbfa
|
File details
Details for the file curses_components-26.7.2-py3-none-any.whl.
File metadata
- Download URL: curses_components-26.7.2-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd1f911ac19a77027cb3a6a1a6eacca8866db1652e35c0912b7facfab00a36af
|
|
| MD5 |
a777800bbed858d3bfa7ea3768f192ec
|
|
| BLAKE2b-256 |
db52bdcf1922e75c46d7197d69cab9cf1c2d58c7b7c681b519ab69378107500b
|