Skip to main content

No project description provided

Project description

Terminapy

Terminapy is a lightweight Python library for creating a simple ASCII/Unicode-based terminal "screen" with sub-screens. It allows you to divide the terminal into multiple panels, each managed independently, and safely share screens between threads.

What Is It For?

Terminapy provides a Screen class that help you create and manage a display of the terminal:

╭───────────────────────┬───────────────────────╮
│                       │                       │
│                       │                       │
│      Sub-Screen 1     │     Sub-Screen 2      │
│   (displaying text)   │  (displaying text 2)  │
│                       │                       │
│                       │                       │
╰───────────────────────┴───────────────────────╯

the lib provide function to print directly the screen on the terminal but you can get the screen as a str and display it on you own there will be some example

External Lib use:

In this lib i will try to use as little as possible external lib

  • os
  • math
  • time
  • threading

Installation

pip install terminapy

Usage Examples

Simple loop

import terminapy as tp

screen = tp.screen()
while True:
    screen.draw_terminal_screen()

Split vertically

import terminapy as tp

screen = tp.screen()
screen.split_vertical(0.5)
while True:
    screen.draw_terminal_screen()

Updating content

import terminapy as tp
import time

screen = tp.screen()
screen.split_vertical(0.5)
left = screen.get_screen(0)
right = screen.get_screen(1)

left.append("Left panel: Hello!")
right.append("Right panel: Counter")

counter = 0
while True:
    counter += 1
    right.rewrite_last_line(f"Right panel: {counter}")
    screen.draw_terminal_screen()
    time.sleep(1)

Threading Example

import terminapy as tp
import threading
import time

def worker(sub):
    for i in range(20):
        sub.append(f"Thread says {i}")
        time.sleep(0.5)

screen = tp.screen()
screen.split_vertical(0.5)
left = screen.get_screen(0)
right = screen.get_screen(1)

t = threading.Thread(target=worker, args=(right,))
t.start()

for _ in range(40):
    screen.draw_terminal_screen()
    time.sleep(0.25)
t.join()

API Reference

Method Description
screen(name: str) Create a new main screen
split_horizontally(ratio: float) Split top/bottom
split_vertically(ratio: float) Split left/right
change_line(lines:list[str],copy:bool = True) Replace all the previous lines by the new line
append(message: str) Append text to sub-screen
clear() Clear a screen
rewrite_last_line(message: str) Replace last line
get_screen(index: int) Get a sub-screen
get_terminal_screen() Get the str of the screen (what is use in draw_terminal_screen)
draw_terminal_screen() Render terminal screen
full_autonome(refresh_rate : float) Start a thread and refresh the terminal on it's own you do not need to have a loop do draw the screen on the terminal

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

terminapy-0.0.2.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

terminapy-0.0.2.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file terminapy-0.0.2.1.tar.gz.

File metadata

  • Download URL: terminapy-0.0.2.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for terminapy-0.0.2.1.tar.gz
Algorithm Hash digest
SHA256 b4933466e2e0f24c89ab50607b1a578c4dcee20ed6c7cb5f86c1a9c7507922e2
MD5 229b598a485b50f85980defc9c97cf30
BLAKE2b-256 893024daf081de9aec46f24ec741dbe8907c4da0c3ba737224fc9f15824c47a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for terminapy-0.0.2.1.tar.gz:

Publisher: release.yml on Klem10013/terminapy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file terminapy-0.0.2.1-py3-none-any.whl.

File metadata

  • Download URL: terminapy-0.0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for terminapy-0.0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae464fa1e85adb2acd94afb52368158b07daf32306e3aa290ffa6b065cf35165
MD5 f4a0e2733a720ea493e15f81bf92ad05
BLAKE2b-256 a1c8ef2b77d53e100759b1d7ad4aebd903d919f37960efc866c44fd346886807

See more details on using hashes here.

Provenance

The following attestation bundles were made for terminapy-0.0.2.1-py3-none-any.whl:

Publisher: release.yml on Klem10013/terminapy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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