Code Monkey home page Code Monkey logo

colorprt's Introduction

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))

colorprt's People

Contributors

michaelzhouisnotwhite avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.