Skip to main content

Package to simplify printing colors in the console.

Project description

Project logo

Pcolors

GitHub issues GitHub forks GitHub stars GitHub license


Pcolors is made to simplify printing colors in the console.

:pencil: Table of Contents

🧐   About

This package is perfect if you want to display fancy text on the console without having to worry about ANSI escape codes ASGR sequences and all theses boring an complicated stuff Pcolors do all that for you

🏁   Getting Started

Installing

You can install Pcolors using pip:

pip install Pcolors

to verify the installation you can do

python -m Pcolors

📚   Usage

cprint

cprint() is the base function of Pcolors use it to directly print colored text using the styling rules:

cprint("text", styling rules)

from Pcolors import cprint

cprint("text", fg_color="red", bg_color="lblue")

style

style() is used to define styles using the styling rules:

from Pcolors import style

header = style(
	fg_color="green",
	bg_color="lblack",
	format=["framed", "bold", "underline_bold"],
)

cprint("my header", style=header)
...
cprint("my second header", style=header)

🖌   styling rules

color

use fg_color and bg_color to define the forground color and the background color

from Pcolors import cprint, style

cprint("text", fg_color="red", bg_color="lblue")
style(fg_color="red", bg_color="lblue")

you can use color names:

  • white / lwhite
  • cyan / lcyan
  • magenta / lmagenta
  • blue / lblue
  • yellow / lyellow
  • green / lgreen
  • red / lred
  • black / lblack

or you can use codes:

  • 97 / 37
  • 96 / 36
  • 95 / 35
  • 94 / 34
  • 93 / 33
  • 92 / 32
  • 91 / 31
  • 90 / 30

end

use end to define what should be appended to the output, default : "\n"

from Pcolors import cprint, style


cprint("text", fg_color="red", bg_color="lblue", end="")
style(fg_color="red", bg_color="lblue", end="")

defining end to "" make the print don't go to a new line at the end permitting to print multiple colors on a single line

format

use format to define the formatting of the text

from Pcolors import cprint, style


cprint("text", format=["bold","underline"])
style(format=["bold","underline"])

you can use format names:

  • normal
  • bold
  • faint
  • italic
  • underline
  • slow_blink
  • rapid_blink
  • reverse
  • hidden
  • crossed
  • underline_bold
  • framed
  • rounded

or you can use codes:

  • 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 21
  • 51
  • 52

✒   shortcuts

you can also use shortcuts for styling :

you can found them in Pcolors.shortcuts

from Pcolors import style
from Pcolors.shortcuts import light, dark, format


header = style(
	fg_color=dark.green,
	bg_color=light.black,
	format=[
		format.framed,
		format.bold,
		format.underline_bold
	],
)

or for using manually with code() and styling rules:

from Pcolors import code
from Pcolors.shortcuts import light, dark, format

code(light.green) #>

✍️   Authors

🔎   Examples

powershell

Project logo

cmd

Project logo

windows terminal

Project logo

pycharm

Project logo

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

Pcolors-0.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

Pcolors-0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file Pcolors-0.1.tar.gz.

File metadata

  • Download URL: Pcolors-0.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for Pcolors-0.1.tar.gz
Algorithm Hash digest
SHA256 1de4ee2cd035cd7f4eff733c0bed93e3a18a6bd8c130c57e2dc9412e65eca311
MD5 57447e5b5a2788484c7da03fdcba17b8
BLAKE2b-256 f6b18d576eeadbe39a5ded9e307160d83976c02ae4bc36cfd13579e766cfff86

See more details on using hashes here.

File details

Details for the file Pcolors-0.1-py3-none-any.whl.

File metadata

  • Download URL: Pcolors-0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for Pcolors-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ef87fb0c816d18a297e509a0d8e1d0ff9f679c8cfd9c1098017aa79ef57896d
MD5 88e599dc758d69f07fdbb662d1b256ec
BLAKE2b-256 7d9cee979728d1411a84748d688391537e7b99b1994583ca347f02db99a7298c

See more details on using hashes here.

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