A library for creating a terminal user interface
Project description
Colorlib
A library designed for making working with terminal user interfaces easier
Features
Colorlib can
- Handle colors for you
- Generate boxes
- Manipulate text alignment
- And more
Key features
Colors
Colorlibis designed to make coloring elements a bit easier. You can color logos, ansi art or whatever you'd like and print that out to a terminal. Here's a demo
import src
logo = """
██████ ▄▄▄ ███▄ ▄███▓ ██▓███ ██▓ ▓█████ ▄▄▄█████▓▓█████ ▒██ ██▒▄▄▄█████▓
▒██ ▒ ▒████▄ ▓██▒▀█▀ ██▒▓██░ ██▒▓██▒ ▓█ ▀ ▓ ██▒ ▓▒▓█ ▀ ▒▒ █ █ ▒░▓ ██▒ ▓▒
░ ▓██▄ ▒██ ▀█▄ ▓██ ▓██░▓██░ ██▓▒▒██░ ▒███ ▒ ▓██░ ▒░▒███ ░░ █ ░▒ ▓██░ ▒░
▒ ██▒░██▄▄▄▄██ ▒██ ▒██ ▒██▄█▓▒ ▒▒██░ ▒▓█ ▄ ░ ▓██▓ ░ ▒▓█ ▄ ░ █ █ ▒ ░ ▓██▓ ░
▒██████▒▒ ▓█ ▓██▒▒██▒ ░██▒▒██▒ ░ ░░██████▒░▒████▒ ▒██▒ ░ ░▒████▒▒██▒ ▒██▒ ▒██▒ ░
▒ ▒▓▒ ▒ ░ ▒▒ ▓▒█░░ ▒░ ░ ░▒▓▒░ ░ ░░ ▒░▓ ░░░ ▒░ ░ ▒ ░░ ░░ ▒░ ░▒▒ ░ ░▓ ░ ▒ ░░
░ ░▒ ░ ░ ▒ ▒▒ ░░ ░ ░░▒ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░░ ░▒ ░ ░
░ ░ ░ ░ ▒ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
"""
print(src.coloring.colorize_with_gradient(logo, (2, 45, 189), (189, 2, 99), 45).to_ansi_escape_sequences())
You can also make radial gradients, like this
import src
logo = """
██████ ▄▄▄ ███▄ ▄███▓ ██▓███ ██▓ ▓█████ ▄▄▄█████▓▓█████ ▒██ ██▒▄▄▄█████▓
▒██ ▒ ▒████▄ ▓██▒▀█▀ ██▒▓██░ ██▒▓██▒ ▓█ ▀ ▓ ██▒ ▓▒▓█ ▀ ▒▒ █ █ ▒░▓ ██▒ ▓▒
░ ▓██▄ ▒██ ▀█▄ ▓██ ▓██░▓██░ ██▓▒▒██░ ▒███ ▒ ▓██░ ▒░▒███ ░░ █ ░▒ ▓██░ ▒░
▒ ██▒░██▄▄▄▄██ ▒██ ▒██ ▒██▄█▓▒ ▒▒██░ ▒▓█ ▄ ░ ▓██▓ ░ ▒▓█ ▄ ░ █ █ ▒ ░ ▓██▓ ░
▒██████▒▒ ▓█ ▓██▒▒██▒ ░██▒▒██▒ ░ ░░██████▒░▒████▒ ▒██▒ ░ ░▒████▒▒██▒ ▒██▒ ▒██▒ ░
▒ ▒▓▒ ▒ ░ ▒▒ ▓▒█░░ ▒░ ░ ░▒▓▒░ ░ ░░ ▒░▓ ░░░ ▒░ ░ ▒ ░░ ░░ ▒░ ░▒▒ ░ ░▓ ░ ▒ ░░
░ ░▒ ░ ░ ▒ ▒▒ ░░ ░ ░░▒ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░░░ ░▒ ░ ░
░ ░ ░ ░ ▒ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
"""
print(src.coloring.colorize_with_circle_gradient(logo, (2, 45, 189), (189, 2, 99), 60, 0.4,
0.2).to_ansi_escape_sequences())
Box generation
Colorlib can generate boxes for you, for text you input. An example:
from src import colorlib
logo = """This text is multiline
I can type whatever I want and the box will fit it
This is a nice library"""
print(src.colorlib.boxes.generate_text_box(logo, src.colorlib.boxes.BoxTypes.rounded.value))
You can also change the box layout, see BoxType in boxes.py
Manipulate text alignment
Colorlib can also help you align text, here's an example
import src
logo = """This text is centered
It is centered because I want it to be
Very nice, will fit whatever"""
print(src.text_manipulation.center_text_in_itself(logo))
You can also right align text:
import src
logo = """This text is right aligned
Just because, no particular reason
Nice weather outside today, isn't it?"""
print(src.text_manipulation.right_align_text(logo))
There are many more features, the api is pretty self explanatory.
Support
You can show your support by leaving a star on this repo, which would help me out a lot! Also, if you find any bugs, don't hesitate to open up an issue for it.
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
Hashes for tui_colorlib-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82c92d923104baada54d891958256b7bc468ef400b48e62097c75486eabb65c0 |
|
MD5 | 2128966d9e34aa640088a95c6d1cc41c |
|
BLAKE2b-256 | 0413676cdfdf0bbeafd356597aac894a9b357ac726204cbd46c54bbb990b6e39 |