Skip to main content

Simple package to print colored messages using ASCI to the terminal.

Project description

terminalcolorpy

License

made-with-python

This is a simple package to print colored messages using ASCI to the terminal built with python 3.

Installation

# Linux/MacOS
python3 -m pip install terminalcolorpy

# Windows
py -m pip install terminalcolorpy

For the dev version, do:

git clone https://github.com/ammarsys/terminalcolorpy
cd terminalcolorpy

Usage of terminalcolorpy

Usage of it is pretty straight-forward,

import terminalcolorpy as tp

print(tp.colored('Hello', color='#42f5d7',
         markup=['striked', 'bold', 'underline', 'italic'],
         highlight='#a8328b')
      )

TerminalColorPy has 4 main functions,

  • prainbow
  • colored
  • blink
  • printcolor
  • flip_text

prainbow It's alias is pr, takes a single parameter which is text to return as rainbow.

colored It's alias is c, takes 4 parameteres, which are:

  • text (mandatory)
    • text to colorify
  • color (mandatory)
    • color for the text
  • highlight (optional)
    • highlight for the text
  • markup (optional)
    • markup for the text

blink It's alias is b, takes 2 parameterers, which are:

  • message (mandatory),
    • initial message to print
  • lenght (optional)
    • how long til the initial message should change
  • new_message (optional)
    • what to replace initial message with, default ''

printcolor It's alias is pc, takes 2 parameters, which are:

  • print_arguments (optional)
    • arguments for the builtin python3 print function
  • kwargs (mandatory)
    • keyword arguments for the terminalcolorpy.colored function

Message is the string to print to the console, lenght is how long it should stay and new message is what it should be replaced with.

HighLight & Color take either a string, an RGB value or even a hex code. For example,

from terminalcolorpy import colored, blink, printcolor

print(colored('Hello', color='#42f5d7',
         markup=['striked', 'bold', 'underline', 'italic'],
         highlight='#42f5d7')
      )

print(colored('World', color='red',
         markup=['striked', 'bold'],
         highlight='blue')
      )

blink(colored('!', color=[122, 99, 0],
         markup=['bold'],
         highlight=[122, 100, 78])
      )
      
printcolor({'end': ''}, color='blue', text='Hello')

For more examples check tests/tests.py (github)

List of accepted values

    
    # these aren't CaSe SeNsItIvE!
    
highlight_values = [
        'gray',
        'pink',
        'black',
        'yellow',
        'green',
        'blue',
        'red'
]

color_values = [
        'pink',
        'blue',
        'cyan',
        'green',
        'yellow',
        'red',
        'black',
        'orange'
]

text_markup_values = [
        'bold',
        'underline',
        'italic',
        'striked'
]

Hex Generator https://www.google.com/search?q=hex+color

RGB Generator https://www.w3schools.com/colors/colors_rgb.asp

It works on any terminals that support ASCII codes, include but not limited to:

To use this in a Windows terminal, simply make a empty system call which enables colors in the terminal:

import os; os.system('')'

Terminals Works On
PyCharm True
Python IDLE False
Windows CMD True (limited!)
Mac-OS iTerm2 True
VSCode True
Visual Studio Code True

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

terminalcolorpy-0.1.2.tar.gz (8.8 kB view hashes)

Uploaded Source

Built Distribution

terminalcolorpy-0.1.2-py3-none-any.whl (9.2 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