Simple package to print colored messages using ASCI to the terminal.
Project description
terminalcolorpy
This is a simple package to print colored messages using ASCI to the terminal built with python 3.
Installation
# Linux/MacOS
python3 -m pip install terminalcolorpy
# Windows
py -m pip install terminalcolorpy
For the dev version, do:
git clone https://github.com/ammarsys/terminalcolorpy
cd terminalcolorpy
Usage of terminalcolorpy
Usage of it is pretty straight-forward,
import terminalcolorpy as tp
print(tp.colored('Hello', color='#42f5d7',
markup=['striked', 'bold', 'underline', 'italic'],
highlight='#a8328b')
)
TerminalColorPy has 4 main functions,
- prainbow
- colored
- blink
- printcolor
- flip_text
prainbow It's alias is pr, takes a single parameter which is text to return as rainbow.
colored It's alias is c, takes 4 parameteres, which are:
- text (mandatory)
- text to colorify
- color (mandatory)
- color for the text
- highlight (optional)
- highlight for the text
- markup (optional)
- markup for the text
blink It's alias is b, takes 2 parameterers, which are:
- message (mandatory),
- initial message to print
- lenght (optional)
- how long til the initial message should change
- new_message (optional)
- what to replace initial message with, default ''
printcolor It's alias is pc, takes 2 parameters, which are:
- print_arguments (optional)
- arguments for the builtin python3 print function
- kwargs (mandatory)
- keyword arguments for the terminalcolorpy.colored function
Message is the string to print to the console, lenght is how long it should stay and new message is what it should be replaced with.
HighLight & Color take either a string, an RGB value or even a hex code. For example,
from terminalcolorpy import colored, blink, printcolor
print(colored('Hello', color='#42f5d7',
markup=['striked', 'bold', 'underline', 'italic'],
highlight='#42f5d7')
)
print(colored('World', color='red',
markup=['striked', 'bold'],
highlight='blue')
)
blink(colored('!', color=[122, 99, 0],
markup=['bold'],
highlight=[122, 100, 78])
)
printcolor({'end': ''}, color='blue', text='Hello')
For more examples check tests/tests.py (github)
List of accepted values
# these aren't CaSe SeNsItIvE!
highlight_values = [
'gray',
'pink',
'black',
'yellow',
'green',
'blue',
'red'
]
color_values = [
'pink',
'blue',
'cyan',
'green',
'yellow',
'red',
'black',
'orange'
]
text_markup_values = [
'bold',
'underline',
'italic',
'striked'
]
Hex Generator https://www.google.com/search?q=hex+color
RGB Generator https://www.w3schools.com/colors/colors_rgb.asp
It works on any terminals that support ASCII codes, include but not limited to:
To use this in a Windows terminal, simply make a empty system call which enables colors in the terminal:
import os; os.system('')'
Terminals | Works On |
---|---|
PyCharm | True |
Python IDLE | False |
Windows CMD | True (limited!) |
Mac-OS iTerm2 | True |
VSCode | True |
Visual Studio Code | True |
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 terminalcolorpy-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5294d07e41f5b0ad3213c7c14ad39246518bcaaa1d1dc17b94b35df4981f50f5 |
|
MD5 | 2c3756f287be5a9672e29d3114b3b253 |
|
BLAKE2b-256 | e053a4474e6a4a9551477765280b103751eaf15f2323972073ee8e2b9359c7ac |