A basic package that makes it easy to add color and styles to your terminal.
Project description
Colors And Styles
A basic package that makes it easy to add color and styles to your terminal.
How to use
First go to the terminal and run pip install Colors-and-Styles
. Then create a Python file and paste this code in it:
from Colors_and_Styles import Color, Style, clear, RESET_ALL
clear
is a function that clears and flushes the terminal.
RESET_ALL
is a string with the ANSI escape code to reset all colors and styles.
Color
Color
has 3 classes: RGB
, Foreground
, and Background
.
As a string, an RGB
value returns an ANSI color code.
RGB
requires 4 arguments:
Parameter | Description |
---|---|
red |
The red value of the RGB. |
green |
The green value of the RGB. |
blue |
The blue value of the RGB. |
isForeground |
Returns a foreground ANSI color code as a string if True . Else returns a background ANSI color code. (Optional) |
Foreground
has 8 class variables:BLACK
,RED
,GREEN
,YELLOW
,BLUE
,MAGENTA
,CYAN
, andRESET
. They are assigned to their respective ANSI color codes. To use these color codes, simply concatenate them with a string like so:
print(f"{Color.Foreground.RED}This text is red.{Color.Foreground.RESET}")
Background
has 9 class variables:BLACK
,RED
,GREEN
,YELLOW
,BLUE
,MAGENTA
,CYAN
,WHITE
andRESET
. To use them, just concatenate them to a string just likeForeground
's class variables:
print(f"{Color.Background.GREEN}This text is green.{Color.Background.RESET}")
Style
Style
has 6 class variables: BOLD
, DIM
, ITALICS
, UNDERLINE
, STRIKETHROUGH
, and RESET
. Like the classes in Color
, they are assigned to their respective ANSI escape codes. Concatenate them to strings to use them:
print(f"{Style.BOLD}This text is bold.{Style.RESET}")
Change Log
1.0.2 (4/26/2023)
- Updated
pyproject.toml
1.0.1 (4/8/2023)
- Small change to the README
1.0.0 (4/8/2023)
- First release
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 Colors and Styles-1.0.2.tar.gz
.
File metadata
- Download URL: Colors and Styles-1.0.2.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0c4bb613f3571f0539bdce334991a36f625945ac149087162b5e32ec6396754 |
|
MD5 | 1f49ea6a6f93c630918616531bbe5e05 |
|
BLAKE2b-256 | 4beb290c00837e0c40dcbaa29dbc7ffdc21a801072df587b0d073b2eb9ff0f5c |