Skip to main content

A simple styling package for making console programmes great again.

Project description

Colorain v0.0.28

Ever wondered how people make those console programmes print in pretty colours? Well, the answer is simple: there are ANSI colour codes with which you have to tag up the text. The problem is, the codes are pretty complicated, and so typically people write bland, all-whites console programmes. Colorain is a package that makes printing coloured text to the console a piece of cake. Using a simple markup designed just for colouring text on the terminal, Colorain allows you to quickly add colours to any Python project you might have. There's a few other packages that help you to print colourful text with Python, but none with the ease of use as Colorain.

Installation

pip install colorain

Usage

Using a very simple markup that kinda looks like HTML, you can easily modify the colour of different parts of some text. The following example is pretty self explanatory. The general syntax is as follows: <f=C>Text</> colours the foreground with colour C, i.e. the text, <b=C>Text</> colours the background with colour C, and <f=C1;b=C2>Text</> or <b=C2;f=C1> colours the foreground with C1 and the background with C2. Aside from the markups, there's also some utility wrapper classes if you need to colour some large chunk of text in the same colour.

from colorain import *
# parses the colour tags and colour-codes the text as needed
txt = StyledText('<f=y>Okay</>, workin <f=y;b=r>fine</>') 

# prints the coloured text
print(txt) 

# strips off the colour tags and gives the raw text
print(txt.raw_text()) 

# we've overloaded the plus operator for you
# so that you can manipulate your strings just
# as usual
print(txt + FGRed("\nOr is it?") + "\n*VSauce background intensifies*")

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

colorain-0.0.28.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

colorain-0.0.28-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file colorain-0.0.28.tar.gz.

File metadata

  • Download URL: colorain-0.0.28.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.8

File hashes

Hashes for colorain-0.0.28.tar.gz
Algorithm Hash digest
SHA256 e7e39c699a29b756fcd1f370d0e98b6016b225e51e20b3430b4fc5e6b523e643
MD5 c15e14d4e4108cb47b23ba112cafbba3
BLAKE2b-256 3f88597a7199495c7cb66ca33ae8c14586ab43fd896c58236d2c1e6473346f75

See more details on using hashes here.

File details

Details for the file colorain-0.0.28-py3-none-any.whl.

File metadata

  • Download URL: colorain-0.0.28-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.8

File hashes

Hashes for colorain-0.0.28-py3-none-any.whl
Algorithm Hash digest
SHA256 4ca2642a84f9a9e754df69de5f75ba055fbae3b872614b23a4f6288f16fc1def
MD5 19e041b0ed122dd6fcc8a3cec3e63ed2
BLAKE2b-256 119f507ee70fedc27f58e9c72b343cbf23a6021156a2defaff52ce35ae634b6b

See more details on using hashes here.

Supported by

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