Giter VIP home page Giter VIP logo

pylor's Introduction

pylor

Library for outputting colorful text

Supports 16 foreground and 16 background colors


Color table

Table from Wikipedia


QuickStart

Use: pip install pylor to install the module.

Imports

import pylor
from pylor import colors # Imports class full of colors to choose from
from pylor import decorations # Imports class full of decorations
from pylor import cursor # Imports class for cursor movement

Testing the installation

import pylor
print( pylor.test() ) # This will print the project logo

Functions

color()

The color function is used to create colored strings.

Arguments:

  • String
  • Foreground color
  • Background color [Optional]

Example:

import pylor
from pylor import colors

print( pylor.color("Hello world!", colors.foreground.red) )

Returns string


colorNoReset()

The color function is used to create colored strings, does not set the color back to default (continues to color any future output).

Arguments:

  • String
  • Foreground color
  • Background color [Optional]

Example:

import pylor
from pylor import colors

print( pylor.colorNoReset("Hello world!", colors.foreground.red) )

Returns string


formatting()

Function used for formatting text.

Arguments:

  • String
  • Formatting type

Example:

import pylor
from pylor import decorations

print( pylor.formatting("Hello world!", decorations.bold) )

Returns string


formattingNoReset()

Function used for formatting text, does not set the color back to default (continues to decorate any future output).

Arguments:

  • String
  • Formatting type

Example:

import pylor
from pylor import decorations

print( pylor.formatting("Hello world!", decorations.bold) )

Returns string


reset()

Function used for resetting the color after using colorNoReset()

Arguments:

  • None

Example:

import pylor

print( pylor.reset() )

Returns string


test()

Function for testing the installation of the package, returns the project logo.

Arguments:

  • None

Example:

import pylor

print( pylor.test() )

Returns string


Codes

Colors

Foreground

colors.foreground.

red
black
green
yellow
blue
magenta
cyan
white
brightBlack
brightRed
brightGreen
brightYellow
brightBlue
brightMagenta
brightCyan
brightWhite

Background

colors.background.

red
black
green
yellow
blue
magenta
cyan
white
brightBlack
brightRed
brightGreen
brightYellow
brightBlue
brightMagenta
brightCyan
brightWhite

Decorations

decorations.

bold
underline
reverse

Cursor

cursor.

up
down
right
left

Exceptions

NotAColor

Exception for when the argument given is not an ANSI code.

Example of code that would trigger this Exception:

import pylor
from pylor import colors

print( pylor.color("Hello world!", "red") ) # This is an example of bad code, do not use this, it will not work.

correct code:

import pylor
from pylor import colors

print( pylor.color("Hello world!", colors.foreground.red) )

SameType

Exception for when the background/foreground colors are used twice.

Example of code that would trigger this Exception:

import pylor
from pylor import colors

print( pylor.color("Hello world!", colors.foreground.red, colors.foreground.green) ) # This is an example of bad code, do not use this, it will not work.

correct code:

import pylor
from pylor import colors

print( pylor.color("Hello world!", colors.foreground.red, colors.background.red) )

pylor's People

Contributors

mirandaniel avatar

Stargazers

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