promptabs - Interactive Terminal Survey Module
A Python module for creating interactive terminal-based surveys with tab navigation and arrow key support.
Features
- Tab-based Navigation: Use left/right arrow keys to navigate between questions
- Arrow Key Selection: Use up/down arrow keys to select answer options
- Colorized Output: Beautiful terminal UI with ANSI colors
- Easy Integration: Simple API for creating surveys
- Response Collection: Automatically collects user responses in a dictionary
- Submit/Review Tab: Review answers before submitting with validation
- Required Field Validation: Prevent submission if required questions are unanswered
- Optional Questions: Support both required and optional questions
Installation
pip install -e .
Quick Start
from promptabs import Survey, Question
# Create questions
questions = [
Question(
id="q1",
title="What is your favorite programming language?",
options=["Python", "JavaScript", "Go", "Rust"],
description="Select one option"
),
Question(
id="q2",
title="Which OS do you use?",
options=["macOS", "Linux", "Windows"]
),
]
# Run the survey
survey = Survey(questions)
responses = survey.run()
# Access responses
print(responses)
# Output: {"q1": "Python", "q2": "Linux"}
API Documentation
Question
Data class representing a single survey question.
@dataclass
class Question:
id: str # Unique question identifier
title: str # Question title/text
options: List[str] # Available answer options
description: str = "" # Optional question description
required: bool = True # Whether question must be answered
Survey
Main class for managing and running surveys.
survey = Survey(questions: List[Question])
# Run the survey and get responses
responses: Dict[str, str] = survey.run()
Keyboard Controls
The tabs form a circular navigation ring - you can navigate freely between any tabs!
Navigation
- Left Arrow (←): Move to previous tab (wraps from Q1 to Submit)
- Right Arrow (→): Move to next tab (wraps from Submit to Q1)
On Question Tabs
- Up/Down arrows: Select answer options
- Enter: Confirm selection and move to next question
- Esc / Ctrl+C: Cancel survey
On Submit/Review Tab
- Up/Down arrows: Select between Submit and Cancel buttons
- Enter: Submit survey (only if all required questions answered)
- Esc / Ctrl+C: Cancel survey
Example Navigation:
Q1 ← → Q2 ← → Q3 ← → Submit
↑_______________________________↓
(pressing ← on Q1 goes to Submit)
(pressing → on Submit goes to Q1)
Architecture
- question.py: Question data model
- terminal.py: Terminal rendering and UI components
- input_handler.py: Raw keyboard input handling
- survey.py: Main survey conductor and interaction logic
Example Output
☑ Version Storage ☐ Build System ☐ Package Format →
Version Storage Question
Select your preferred approach
❯ Unified version.txt
Platform-specific
Hybrid approach
Other
Use ↑↓ to select · ← → to navigate tabs · Enter to confirm · Esc to cancel
Requirements
- Python 3.10+
- Unix-like terminal (macOS, Linux) or Windows with compatible terminal
License
MIT
Metadata
Release files for promptabs 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| promptabs-0.3.1.tar.gz | 57.0 kB | Without provenance | Details for promptabs-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| promptabs-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for promptabs-0.3.1-py3-none-any.whl |
Total release size: 74.5 kB
Release files / promptabs-0.3.1.tar.gz
| Download URL | promptabs-0.3.1.tar.gz |
|---|---|
| Size | 57.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c328bec4ac292f52bb3464598120f24a1aa85ce85bfac278943eab6578704d99
|
|
BLAKE2b-256 checksum How to use checksums |
b1422453ce89a400998d3114e5696a2f2ac618583becc275d486f2f599806e59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / promptabs-0.3.1-py3-none-any.whl
| Download URL | promptabs-0.3.1-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e1fb8c98cfc7cb051f5b0c33777b81ff54eccfcb22f51ce5a99caf4b6650fff6
|
|
BLAKE2b-256 checksum How to use checksums |
61f5b42e30d76dbde1e49371735966ecc70b8d3edad009c14d4a31238b3b4467
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for promptabs 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.