Skip to main content

console colouring for python

Project description

http://gfxmonk.net/dist/status/project/termstyle.png

termstyle

termstyle is a simple python library for adding coloured output to terminal (console) programs. The definitions come from ECMA-048, the “Control Functions for Coded Character Sets” standard.

Example Usage:

from termstyle import *
print "%s:%s" % (red('Hey'), green('how are you?'))
print blue('How ', bold('you'), ' doin?')

or, you can use a colour just as a string:

print "%sBlue!%s" % (blue, reset)

Styles:

reset or default (no colour / style)

colour:

black
red
green
yellow
blue
magenta
cyan
white

background colour:

bg_black
bg_red
bg_green
bg_yellow
bg_blue
bg_magenta
bg_cyan
bg_white
bg_default

In terminals supporting transparency bg_default is often used to set the background to transparent [1].

weight:

bold
inverted

style:

italic
underscore

Controls:

auto() - sets colouring on only if sys.stdout is a terminal
disabe() - disable colours
enable() - enable colours

Project details


Download files

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

Source Distributions

python-termstyle-0.1.10.tgz (2.9 kB view hashes)

Uploaded Source

python-termstyle-0.1.10.tar.gz (4.1 kB view hashes)

Uploaded Source

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