Add helpful ANSI tools for printing funky text
Project description
terminal_colours
##Add helpful ANSI tools for printing funky text
Author: Michael Stickler
###Contents:
Functions
Colour and Style Code Guide
##Functions
####cprint
######(message, preset=None, fg=None, bg=None, style="", br=False)
Message is required, all other params are optional and can be named.
Prints a message to the screen in a particular colour and style
import terminal_colours.colours as tc
tc.cprint('Hello', fg='r') # prints red text
tc.cprint('Hello', fg='dg', style='bi') # prints dark green, bold italic text
tc.cprint('Hello', preset='error') # prints text with the 'error' preset
####colour
######(message, preset=None, fg=None, bg=None, style="", br=False)
Message is required, all other params are optional and can be named.
Returns a string formatted with a specified colour and style. This can be used to mix styles.
tc.colour('WARNING', preset='warning')
# Returns '\x1b[33;3;4mWARNING\x1b[0m'
print(tc.colour('ERROR: ', preset='error') + "something went wrong!")
#prints an error message and the first word is highlighted
####new_preset
######(name, preset=None, fg=None, bg=None, style="", br=False, test=False)
name is required, all other params are optional and can be named.
Creates a new preset format that you can use with the other commands in this module.
You can also add the test=True parameter to have it print out an example of the preset.
tc.new_preset("important", fg="a530", style="rb")
#creates a new preset called "important"
tc.new_preset("important", fg="a530", style="rb", test=True)
#does the same as the last line, but also gives a sample.
now these presets can be used:
print(tc.colour("ATTENTION! ", "important") + "This message is super duper important")
####style_code
######(fg=None, bg=None, style="", br=False, test=False)
All params are optional and can be named.
Generates a style code that can be added to text. Will also need to be surrounded by ANSI tags:
message = "Red text"
style = tc.style_code(fg = "r")
styled_message = '\x1b[{style}m{message}\x1b[0m)'
####print_rainbow
######(message, rotations=1, style="")
Give it a try, or don't, I definitely didn't spend hours programming this, nope, not at all.
tc.print_rainbow(f'{"~" * 10}HOLY WOW, RAINBOWS!{"~" * 10}', rotations=5, style="b")
tc.print_rainbow(f'{" " * 120}\n' * 40, rotations=81, style="r")
##Colour/style string codes:
Use these in a string whenever a "fg" or "bg" parameter is required
Styles
(some of these may or may not work depending on your terminal):
b: bold
i: italic
u: underline
s: strikethrough
x: blinking
r: reverse
y: fast blinking
f: faint
h: hide
Colours
k: black
r: red
g: green
y: yellow
b: blue
m: magenta
c: cyan
w: white
More colours:
prefix with the following:
l: light colour codes (light and dark may be inverted in dark mode)
lk: light black
lr: red
lg: green
ly: yellow
lb: blue
lm: magenta
lc: cyan
lw: white
d: dark colour codes (light and dark may be inverted in dark mode)
dk: black
dr: tan
dg: green
dy: brown
db: blue
dm: purple
dc: cyan
dw: light grey
a: rgb values in 3 base 6 digits 0-5 digits for r then g then b values e.g:
a000: black
a520: orange
a022: sea green
a225: the best blue
a555: full white
g: greyscale
0-25 brightness
g0 : black
g12: middle grey
g25: white
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 terminal_colours-michaelstickler-1.0.0.tar.gz.
File metadata
- Download URL: terminal_colours-michaelstickler-1.0.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a7f9df86ee8e90b73020115baa18cbf65e149e96f4fd91bee8d38286867755e
|
|
| MD5 |
c0aa4711824657d10f85f0397c825c00
|
|
| BLAKE2b-256 |
03fc58e5ea865c6e25dc1b82b8d3ccbec0a548965db2ac25faa372b0745f862a
|
File details
Details for the file terminal_colours_michaelstickler-1.0.0-py3-none-any.whl.
File metadata
- Download URL: terminal_colours_michaelstickler-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f79a4870baaffd2ded0b4137248dbfae95d7af797b80451266d91e33ce43085a
|
|
| MD5 |
014c75875b7a54ec5089b9cc220e45fc
|
|
| BLAKE2b-256 |
8df97554dbe88237a760461626b4140c204fb2968d9053a769c1d74175ad8408
|