GithubHelp home page GithubHelp logo

colorprint's Introduction

colorprint

colorprint provide unified print method which can output colored text

the best is that it's cross-platform, support linux and win and every terminal(maybe).

how2use

install

pip install colorprint

show example

from colorprint.example import printall
printall()

you can also save it as a.py

python a.py

modeforeback

use

from colorprint.printer import uprint
from colorprint.unicolor import *
uprint("FOREGROUND_GREEN\n", fore=FOREGROUND_GREEN)
uprint("BACKGROUND_WHITE\n", back=BACKGROUND_WHITE)

print("Show Mode:")
uprint("MODE_NORMAL", mode=MODE_NORMAL,end="\n")\
    ("MODE_BLINK",mode=MODE_BLINK)\
    ("MODE_BOLD",mode=MODE_BOLD)\
    ("MODE_HIDE",mode=MODE_HIDE)\
    ("MODE_INVERT",mode=MODE_INVERT)\
    ("MODE_UNDERLINE",mode=MODE_UNDERLINE)

print("Show foreground color.")
uprint("FOREGROUND_BLACK", fore=FOREGROUND_BLACK,end="\n")\
    ("FOREGROUND_DARKBLUE", fore=FOREGROUND_DARKBLUE)\
    ("FOREGROUND_DARKGREEN", fore=FOREGROUND_DARKGREEN)\
    ("FOREGROUND_DARKSKYBLUE", fore=FOREGROUND_DARKSKYBLUE)\
    ("FOREGROUND_DARKRED", fore=FOREGROUND_DARKRED)\
    ("FOREGROUND_DARKPINK", fore=FOREGROUND_DARKPINK)\
    ("FOREGROUND_DARKYELLOW", fore=FOREGROUND_DARKYELLOW)\
    ("FOREGROUND_DARKWHITE", fore=FOREGROUND_DARKWHITE)\
    ("FOREGROUND_DARKGRAY", fore=FOREGROUND_DARKGRAY)\
    ("FOREGROUND_BLUE", fore=FOREGROUND_BLUE)\
    ("FOREGROUND_GREEN", fore=FOREGROUND_GREEN)\
    ("FOREGROUND_SKYBLUE\n", fore=FOREGROUND_SKYBLUE,end="")\
    ("FOREGROUND_RED\n", fore=FOREGROUND_RED)
uprint("FOREGROUND_PINK\n", fore=FOREGROUND_PINK)
uprint("FOREGROUND_YELLOW\n", fore=FOREGROUND_YELLOW)
uprint("FOREGROUND_WHITE\n", fore=FOREGROUND_WHITE)

Api of the method:

def uprint(*args,
           fore=None,
           back = None,
           mode = None,
           sep=" ",
           end="",
           handle = "stdout",
           flush = True):
    '''
    Prints the colored values to sys.stdout or sys.stderr.
    :param fore:
    :param back:
    :param mode: 
    :param sep: string inserted between values, default a space.
    :param end: string appended after the last value, default a newline.
    :param handle: str, "stdout" or "stderr"
        note:the stderr haven't be tested.
    :param flush: whether to forcibly flush the stream.
    :return: uprint method, you can use
        uprint()()()() to output strings with diff color.
    '''

colorprint's People

Contributors

sailist avatar

Stargazers

 avatar

Watchers

 avatar  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.