Skip to main content

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 tersizeX and tersizeY upon 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

pyterappeng-0.2.1.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyterappeng-0.2.1-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file pyterappeng-0.2.1.tar.gz.

File metadata

  • Download URL: pyterappeng-0.2.1.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

Hashes for pyterappeng-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c3b1d125301fc88744bae98091fc1ddbfcfa51adfa42daefee339e10daf4f0c8
MD5 1beb8497b1d0fff3e693b336a25daf7e
BLAKE2b-256 1c32167175e08e4502c9f0b773c2706790124e9bb860420a710c872077471a06

See more details on using hashes here.

File details

Details for the file pyterappeng-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pyterappeng-0.2.1-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

Hashes for pyterappeng-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8488a1fea995d6b81cf6e47b5494491c9897865876c2406ce710ca720f884576
MD5 3347fac9ea7adbcbf3a22fe156c0c4ba
BLAKE2b-256 6e477ba60f6bbc343eea2347de2250ada2e799c63253ea81ebe2a9adeed587b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page