Skip to main content

Print 'text color' and 'text format' on Term with Python

Project description

term-printer

Print 'text color' and 'text format' on Term with Python

※ It may not work depending on the OS and shell used.

PIP

$ pip install term-printer

import

from term_printer import Color, StdText, cprint

If you want to override bultin print function

from term_printer import Color, StdText, cprint as print

Usage

1. Color print

source

from term_printer import Color, StdText, cprint

cprint(StdText("1234567890", Color.BLACK))
cprint(StdText("1234567890", Color.RED))
cprint(StdText("1234567890", Color.GREEN))
cprint(StdText("1234567890", Color.YELLOW))
cprint(StdText("1234567890", Color.BLUE))
cprint(StdText("1234567890", Color.MAGENTA))
cprint(StdText("1234567890", Color.CYAN))
cprint(StdText("1234567890", Color.WHITE))
cprint(StdText("1234567890", Color.DEFAULT))

result

2. Background color print

source

from term_printer import Color, StdText, cprint

cprint(StdText("1234567890", Color.BG_BLACK))
cprint(StdText("1234567890", Color.BG_RED))
cprint(StdText("1234567890", Color.BG_GREEN))
cprint(StdText("1234567890", Color.BG_YELLOW))
cprint(StdText("1234567890", Color.BG_BLUE))
cprint(StdText("1234567890", Color.BG_MAGENTA))
cprint(StdText("1234567890", Color.BG_CYAN))
cprint(StdText("1234567890", Color.BG_WHITE))
cprint(StdText("1234567890", Color.BG_DEFAULT))

result

3. Format print

source

from term_printer import Format, StdText, cprint

cprint(StdText("1234567890", Format.BOLD))
cprint(StdText("1234567890", Format.FAINT))
cprint(StdText("1234567890", Format.ITALIC))
cprint(StdText("1234567890", Format.UNDERLINE))
cprint(StdText("1234567890", Format.BLINK))
cprint(StdText("1234567890", Format.FAST_BLINK))
cprint(StdText("1234567890", Format.REVERSE))
cprint(StdText("1234567890", Format.CONCEAL))
cprint(StdText("1234567890", Format.STRIKE))

result

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

term-printer-1.0.tar.gz (8.6 kB view hashes)

Uploaded Source

Built Distribution

term_printer-1.0-py3-none-any.whl (10.5 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