https://github.com/ax/dye
Lightweight module with ANSI control codes to dye python scripts.
https://github.com/ax/dye
ansi cli color colors lightweight print python script terminal unix
Last synced: about 1 month ago
JSON representation
Lightweight module with ANSI control codes to dye python scripts.
- Host: GitHub
- URL: https://github.com/ax/dye
- Owner: ax
- License: wtfpl
- Created: 2017-10-20T12:05:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-05-24T17:29:51.000Z (over 6 years ago)
- Last Synced: 2025-05-27T01:54:23.169Z (8 months ago)
- Topics: ansi, cli, color, colors, lightweight, print, python, script, terminal, unix
- Language: Python
- Homepage:
- Size: 5.86 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
===
dye
===
Lightweight module with ANSI control codes to dye python scripts.
This package contains just one module,
it consist only on some declaration,
something like:
``RED = \x1b[31m``
The module has the trivial task of extend the namespace of your application to include
terms you can use to color and format terminal output using ANSI control codes.
Usage
-----
.. code:: python
from dye import *
print fg.BLUE+"colorz"+fg.RESET
print fg.LBLUE+"colorz"+fg.RESET
print style.BOLD + fg.GREEN + bg.YELLOW + "colorz" + style.RESET_ALL
The strings contained in the colorz variables are ANSI control codes.
In this set there are:
- the basic 8 colors
.. code:: python
BLACK
RED
GREEN
YELLOW
BLUE
MAGENTA
CYAN
WHITE
- their high intensity versions
.. code:: python
HBLACK
HRED
HGREEN
HYELLOW
HBLUE
HMAGENTA
HCYAN
HWHITE
- The following styles are supported:
.. code:: python
BOLD
DIM
UNDERL
BLINK
REVERSE
HIDDEN
- reset sequences
.. code:: python
RESET_ALL
RESET_BOLD
RESET_DIM
RESET_UNDERL
RESET_BLINK
RESET_REVERSE
RESET_HIDDEN
You can set text color using ``fg`` codes: ``fg.RED``
You can set background color using ``bg`` codes: ``bg.RED``
You can set styles using ``style`` codes: ``style.BOLD``