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
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 terminapy-0.0.3.tar.gz.
File metadata
- Download URL: terminapy-0.0.3.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17ff69c0d188747038aa19c1d53dbe86767ed5b0f4486ed5aa68a3f45fdd7393
|
|
| MD5 |
16a3ada120e9a839cfe1774c7bfcf61e
|
|
| BLAKE2b-256 |
40a1a652244fbc52f5a7ec61f6ae7a3d638e65eaedf9a402f4ede7f2d2cf70d2
|
Provenance
The following attestation bundles were made for terminapy-0.0.3.tar.gz:
Publisher:
release.yml on Klem10013/terminapy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
terminapy-0.0.3.tar.gz -
Subject digest:
17ff69c0d188747038aa19c1d53dbe86767ed5b0f4486ed5aa68a3f45fdd7393 - Sigstore transparency entry: 1201471161
- Sigstore integration time:
-
Permalink:
Klem10013/terminapy@168f107612f2450ed2102781fda5b2d60f4f64ad -
Branch / Tag:
refs/tags/0.0.3 - Owner: https://github.com/Klem10013
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@168f107612f2450ed2102781fda5b2d60f4f64ad -
Trigger Event:
release
-
Statement type:
File details
Details for the file terminapy-0.0.3-py3-none-any.whl.
File metadata
- Download URL: terminapy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebfde45e2c2b7c31defb3bee717a96275bbeaedf7ae20e4f93d308ca7f97c3e4
|
|
| MD5 |
2a400fda500ba645f2e9463fdc1a4b5a
|
|
| BLAKE2b-256 |
ac05c616d6952ea8da1b220065590a48c50bc0a963ac9c462c6c3c3175010164
|
Provenance
The following attestation bundles were made for terminapy-0.0.3-py3-none-any.whl:
Publisher:
release.yml on Klem10013/terminapy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
terminapy-0.0.3-py3-none-any.whl -
Subject digest:
ebfde45e2c2b7c31defb3bee717a96275bbeaedf7ae20e4f93d308ca7f97c3e4 - Sigstore transparency entry: 1201471166
- Sigstore integration time:
-
Permalink:
Klem10013/terminapy@168f107612f2450ed2102781fda5b2d60f4f64ad -
Branch / Tag:
refs/tags/0.0.3 - Owner: https://github.com/Klem10013
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@168f107612f2450ed2102781fda5b2d60f4f64ad -
Trigger Event:
release
-
Statement type: