A simple and robust terminal UI library, written in Python.
Project description
A simple yet powerful TUI framework for your Python (3.9+) applications
pip3 install pytermgui
Core principles
PTG
was written with some core ideas in mind, such as:
- Pythonic syntax
- Flexible systems
- High quality code
- Extensibility by design
from pytermgui import Container, Label
root = Container() + Label("Clean code is [bold]cool[/bold]!")
root.print()
What we provide
- Terminal mouse support
- A fully flegded WindowManager in the terminal
- A cross-platform getch function with key translations
- An interface to most terminal functionality
- A custom markup language with definable tags & macros inspired by Rich
- Tokenizer & optimizer methods for ANSI-sequence strings
- A robust, extensible and customizable Widget class
- helpful CLI tools (
ptg --help
) - Helpful example files covering most of the library
An example to get started with
# Note: This example uses the auto-conversion syntax.
# For more info, check out `help(pytermgui.auto)`.
import sys
from pytermgui import WindowManager, Window
manager = WindowManager()
window = (
Window(min_width=50)
+ "[210 bold]My first Window!"
+ ""
+ "[157]Try resizing the window by dragging the right border"
+ "[157]Or drag the top border to move the window"
+ "[193 bold]Alt-Tab[/bold 157] cycles windows"
+ "[193 bold]CTRL_C[/bold 157] exits the program"
+ ""
+ ["New window", lambda *_: manager.add(window.copy().center())]
+ ["Close current", lambda _, button: manager.close(button.parent)]
+ ["Exit program", lambda *_: sys.exit(0)]
)
manager.add(window)
manager.run()
Some screenshots
Documentation
As the project is in its infancy, dedicated documentation is not yet available.
If you are interested in help about anything the module provides, you can read its docstring:
python3 -c "help(pytermgui.<name>)"
However, proper documentation is coming once the API is stable.
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
pytermgui-0.2.1.tar.gz
(45.5 kB
view details)
File details
Details for the file pytermgui-0.2.1.tar.gz
.
File metadata
- Download URL: pytermgui-0.2.1.tar.gz
- Upload date:
- Size: 45.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb53a3ae2797898bbe9e09618da461c2f3d5344609e43126327486b68c7d4130 |
|
MD5 | 7d0668eacd2468f5b9725f17c6834486 |
|
BLAKE2b-256 | f664f3482c4caf7219658e1420e0683b366438a468c20c135d2f651573d8bdb3 |