You can beautify your python command-line and GUI applications using colors
Project description
ANSI Beautifier
This is a beautifier project to beautify your python command-line or GUI applications.
It uses ANSI Escape codes (\u001b) to color the text.
Installation
pip install ansibeautifier
Usage
from ansibeautifier import Beautifier
b = Beautifier()
print(b.red(text="Hello World", bright=False))
Returns Hello World in red but not bright as we have given the bright=False parameter
The default bright parameter is False.
Variable Usage
You can also store the colored text in a variable
from ansibeautifier import Beautifier
b = Beautifier()
text = b.green(text="Hello World", bright=False)
print(text)
This also prints the same result but in a pythonic way!
Colors supported
- Green - ansibeautifier.Beautifier.green()
- Red - ansibeautifier.Beautifier.red()
- Blue - ansibeautifier.Beautifier.blue()
- Black - ansibeautifier.Beautifier.black()
- White - ansibeautifier.Beautifier.white()
- Yellow - ansibeautifier.Beautifier.yellow()
- Magenta - ansibeautifier.Beautifier.magenta()
- Cyan - ansibeautifier.Beautifier.cyan()
Other functions
- ansibeautifier.Beautifier.always_<color_name>()
It colors the terminal in which you run the python code. It can be reset by using the ansibeautifier.Beautifier.reset_foreground_color() function
from ansibeautifier import Beautifier
b = Beautifier()
print(b.always_white(text="Hello World"))
print(b.reset_foreground_color())
- ansibeautifier.Beautifier.background_<color_name>()
It colors the background of the text to the color specified It can be nullified by the ansibeautifier.Beautifier.reset_background_color() function
from ansibeautifier import Beautifier
b = Beautifier()
print(b.background_black(text="Hello World", bright=True))
print(b.reset_colors())
- ansibeautifier.Beautifier.always_background_<color_name>()
It colors the background of the terminal and the text specified
from ansibeautifier import Beautifier
b = Beautifier()
print(b.always_background_cyan(text="Hello World"))
print(b.reset_colors())
- ansibeautifier.Beautifier.bold()
It returns bold text. It can be neutralized by the ansibeautifier.Beautifier.reset_intensity() function.
from ansibeautifier import Beautifier
b = Beautifier()
print(b.bold(text="Hello World"))
print(b.reset_intensity())
It returns Hello World
- ansibeautifier.Beautifier.underline()
It returns underlined text. It can also be neutralized by the ansibeautifier.Beautifier.reset_intensity() function.
from ansibeautifier import Beautifier
b = Beautifier()
print(b.underline(text="Hello World", always=True))
print(b.reset_intensity())
This underlines all the text in the terminal and the text given.
- ansibeautifier.Beautifier.reverse()
It returns like highlighted text.
from ansibeautifier import Beautifier
b = Beautifier()
print(b.reverse(text="Hello World", always=True))
print(b.reset_intensity())
- ansibeautifier.Beautifier.conceal()
It returns hidden text and you can unhide it by the ansibeautifier.Beautifier.reset_intensity() function.
import time
from ansibeautifier import Beautifier
b = Beautifier()
print("Hello World")
print(b.conceal(text="Hello World"))
print("Hello World")
time.sleep(0.5)
print(b.reset_intensity())
Try this!
Thanks for reading
If you want the source code you can visit my GitHub page https://github.com/BoughtData92730/ansibeautifier
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
File details
Details for the file ansibeautifier-0.0.5.tar.gz
.
File metadata
- Download URL: ansibeautifier-0.0.5.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dca9b17d22df0dcfe5a42e48ea5df5fdf9e288773c39102b990ae84f24cb54c1 |
|
MD5 | c08b23a406a2eb86aef5f7ea52098b56 |
|
BLAKE2b-256 | 33e03679475ddec25a4213f406f0deb14a852dff0df5b0babe6b9ca467621db2 |