An ultra-lightweight and simple Python engine designed for building text-based terminal applications with dynamic line buffering and rendering support.
Project description
pyterappeng (Python Terminal Application Engine)
pyterappeng is an ultra-lightweight engine for creating text and terminal applications in Python. It allows you to initialize text buffers dynamically via properties, track terminal window sizes, use ANSI colors, read instant keypresses, and update the screen content.
Features
- Object-property style line buffering (
pyterappeng.line1,pyterappeng.line2) - Automatic terminal window size detection (
tersizeX,tersizeY) - Built-in update cycle with auto-clearing
- Cross-platform instant keypress handling
- Built-in ANSI color constants
Installation
Copy the pyterappeng.py file into the root directory of your project.
Usage
The engine works on a buffering principle using dynamically generated properties for each line:
import pyterappeng
from pyterappeng import Colors
pyterappeng.create_lines(3)
while True:
pyterappeng.line1 = f"{Colors.GREEN}=== MENU (Width: {pyterappeng.tersizeX}, Height: {pyterappeng.tersizeY}) ==={Colors.RESET}"
pyterappeng.line2 = f"{Colors.CYAN}1. Say Hello{Colors.RESET}"
pyterappeng.line3 = f"{Colors.RED}2. Exit{Colors.RESET}"
pyterappeng.update()
key = pyterappeng.get_key()
if key == '1':
print("Hello World! Press any key to return...")
pyterappeng.get_key()
elif key == '2':
break
API Documentation
create_lines(lines_count: int)
Creates internal properties for storing the lines of your application. Available names range from line1 to line{lines_count}.
line1, line2, ... lineN
Dynamic variables to control the content of each specific row in your application buffer.
tersizeX: int
Contains the current number of characters that fit into a single horizontal row of the terminal window.
tersizeY: int
Contains the current total number of visible rows available in the terminal window.
update(clear: bool = True)
Prints all active lines (line1, line2, etc.) to the console. Clears the screen before rendering by default.
get_key() -> str
Reads a single keypress from the user instantly without waiting for the Enter key. Works on Windows, Linux, and macOS.
Colors
A class containing ANSI escape codes for text styling: RESET, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, and BOLD.
Roadmap
- Real-time update of
tersizeXandtersizeYupon window resize events - Implement custom UI components (text inputs, checkboxes)
License
This project is licensed under the GNU General Public License (GPL).
Project details
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 pyterappeng-0.2.2.tar.gz.
File metadata
- Download URL: pyterappeng-0.2.2.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fa826e157d3f44017c35de33416c2734fe6943e42817ce78908c35393548d1c
|
|
| MD5 |
db8fa27c2f840a5b257c3b5e9dead5e7
|
|
| BLAKE2b-256 |
b78a1b178a71e8b1dc94ffcee30c17052d81de20ce667f4f74aa7b40a8e4a083
|
File details
Details for the file pyterappeng-0.2.2-py3-none-any.whl.
File metadata
- Download URL: pyterappeng-0.2.2-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90368b39e5de45c52e5f93702e4dfc539a31c2e7f94f06fdf032fef970b69cdf
|
|
| MD5 |
d030f88cd7e7eeb6aad57e91781b975a
|
|
| BLAKE2b-256 |
7c695490972eebd8e4d114c24a2760d92ab04bb2548292b0fa2fde6f598152ec
|