Skip to main content

It's a simple tools to print colorfully. Easy to use

Project description

Colorprt

English | 中文

It's a simple package for you to customize the console printing color.

pypi: https://pypi.org/project/colorprt/

ScreenShots

img.png

New Features

We add some default color config in our package.

from colorprt.default import warn_color, success_color, error_color

warn_color.print("Print a warn message")
success_color.print("Print a success message")
error_color.print("Print an error message")

We found that some people use this package on linux server, so that there is no auto completions. It will trouble users. Therefore, we add a feature that You don't need to type: mode=; foreground=; background=

just call functions or class like this:

In old versions:

from colorprt import colorprt, Back, Fore

# CAUTION: Do not use this after version: 3.0.0
colorprt("Hello World", backgound=Back.RED)

Use new features:

from colorprt import colorprt, Back, Fore

colorprt("Hello World", Back.RED, Fore.YELLOW)

Usage

Installation

pip install colorprt

Detailed Documentation

Function colorprt is a print funtion extention. You can customize the printing style.

from colorprt import colorprt, Back, Fore

hello_else = "Hello Michael"
colorprt("Hello World",hello_else,  Back.RED, Fore.BLUE end="x100 times\n")

scshots01

  • Back stands for background;
  • Fore stands for foreground;
  • Mode stands for printing mode. ( font style like: underline, bold, flash, reverse )

Also, you can use ColorprtConfig class to set colored strings.

from colorprt import ColorprtConfig, Mode, Back, Fore

pycolor_config = ColorprtConfig(Mode.BOLD, Back.DEFAULT, Fore.RED)

# You can use ColorprtConfig to set a color string configuration

colored_formatted_str = pycolor_config("I love You!!")

print(colored_formatted_str)

# or just use print method

pycolor_config.print("I love you!!", end="x10086\n")

If you just want the ansi colored formatted strings, you can use colorstr class.

from colorprt import colorstr, Mode, Back, Fore, ColorprtConfig

hate_print_config = ColorprtConfig(Mode.UNDER_LINE, Back.DEFAULT, Fore.YELLOW)
print(colorstr("I love You!!", Mode.BOLD, Back.DEFAULT, Fore.RED)
      + colorstr("I hate you", hate_print_config))

if you use str() to force change to string. You will get

>>> str(colorstr("I love You!!", Mode.BOLD, Back.DEFAULT, Fore.RED)
      + colorstr("I hate you", hate_print_config))
>>> '\x1b[0m\x1b[1;31mI love You!!\x1b[0m\x1b[4;33mI hate you\x1b[0m\x1b[0m'
from colorprt import colorstr, Mode, Back, Fore, ColorprtConfig

hate_print_config = ColorprtConfig(Mode.UNDER_LINE, Back.DEFAULT, Fore.YELLOW)

output = str(colorstr('I hate You', hate_print_config))

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

colorprt-3.0.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file colorprt-3.0.2-py3-none-any.whl.

File metadata

  • Download URL: colorprt-3.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for colorprt-3.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ef6c601abfb1503a15a62777fd0d6deaf46c38bb0a455b268ff87ccca8350656
MD5 451a8655a3c9e2fc2742df5cfc4f735a
BLAKE2b-256 182ba39abed540e282d1b41bdce51f886f8a349bc53a26404c7107dedd6cb313

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