Skip to main content

Color the text in your terminal.

Project description

ColoredTerm

Downloads

Coloredterm is a collection of functions to help you make text in your terminal a different color.

With fg, bg, Fore, Back, Style, colored and cprint functions.

Examples

Here we will show lots of examples with coloredterm functions.

ForeGround

The ForeGround function can be found as fg. The function lets you change the terminal foreground. Here is an example:

from coloredterm import fg
print(f'{fg("#0000ff")}ForeGround')

This will output: ForeGround This will also work if you use a rgb value.

Just put in fg((0, 0, 255)), Changing the tuple to have the r, g and b value you want it to have.

BackGround

The BackGround function found as bg is very similar to the ForeGround function.

It runs the same way but changes the background instead of the foreground.

Here is an example:

from coloredterm import bg
print(f"{bg('#00ff00')}BackGround")

This will output: BackGround

Same as in ForeGround rgb values work by putting in a tuple.

Style

Now here comes the style class.

Style is a collection of different items you can use to change how the terminal works.

Here is the list:

RESET: Reset all colors and backgrounds. BOLD: Make all text bold. DIM: Make the text dimmer. UNDERLINE: Underline all text. BLINK: Make the text blink. REVERSE: Turn the foreground to the background and background to the foreground. HIDDEN: Turn text invisible.

To use any of these just put in your terminal:

from coloredterm import Style
print(Style.BOLD+"Bold")
print(Style.RESET) # Reset the style after every line so there is no overlapping.
print(Style.DIM+"Dim")
print(Style.RESET) # Reset the style after every line so there is no overlapping.
print(Style.UNDERLINE+"Underline")
print(Style.RESET) # Reset the style after every line so there is no overlapping.
print(Style.BLINK+"Blink")
print(Style.RESET) # Reset the style after every line so there is no overlapping.
print(Style.REVERSE+"Reverse")
print(Style.RESET) # Reset the style after every line so there is no overlapping.
print(Style.HIDDEN+"Hidden")

Running this looks like:

Fore

Now for the Fore function. The Fore function has 14 colors.

These are the colors:

BLACK, RED, GREEN, YELLOW, BLUE, PURPLE, CYAN, WHITE, LIGHTBLACK_EX, LIGHTRED_EX, LIGHTGREEN_EX, LIGHTYELLOW_EX, LIGHTBLUE_EX, LIGHTMAGENTA_EX, LIGHTCYAN_EX, LIGHTWHITE_EX.

As an example of using them:

from coloredterm import Fore
print(Fore.BLUE)

You can replace blue with any color on the list above.

Back

Back is almost the same as Fore. The only difference is that it fills the background while Fore fills the foreground. Back has the same colors as Fore to apply it just use:

from coloredterm import Back
print(back.GREEN)

You can replace blue with any color on the list.

Colored

Colored has the same colors as Fore and Back being this list.

It lets you use background, foreground and style.

Here is a example:

from coloredterm import colored
print(colored("Colored", "blue", "green", "bold"))

This outputs:

Only text is required for the colored function. To change text color alone you can do color = "" To change the background alone you can do on_color = "" To change the style you can do style = ""

Cprint

The cprint function is a combination of print and colored. It takes the same variables but just cprint("Cprint", "blue", None, "bold") instead of print(colored("Cprint", "blue", None, "bold")).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coloredterm-0.0.3.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

coloredterm-0.0.3-py3-none-any.whl (5.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page