Simple Python Library to display text with color in Python Terminal

Overview

pyTextColor v1.0

Introduction

pyTextColor is a simple Python Library to display colorful outputs in Terminal, etc.

Note: Your Terminal or any software in which you are going to print a text should support the ANSI Escape Sequences or it may not work!

Install

To install this library, type pip install pyTextColor in the Terminal(command prompt)

Import

To import the library, use the following code:

import pyTextColor

Print Basic Colored Output

See the following program to print a colorful text in Python!

import pyTextColor  # Import the library

pytext = pyTextColor.pyTextColor()  # Create an object of the pyTextColor class

text = pytext.format_text(text="Hi!", color="white",
                          bgcolor="black")  # Format the text with the color/bgcolor of your choice

print(text)  # Print the text

The above program will give the output as:

Image 1

You can also change the style/color/background of the text!

Following is a list of all color names you can use for both background and text:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

Note: You can also use HEX color values to color a text or background. Remember: HEX color values should have '#' before the main color value

Example Code:

import pyTextColor

pytext = pyTextColor.pyTextColor()

text = pytext.format_text(text="This text will be printed out in yellow color with red background", color="#ff0000",
                          bgcolor="#FFFF00")  # HEX values

print(text)  # Print the text

The output of the above code will be:

Image 2

Text Styles

There are many text styles you can use. Use the text_style parameter to change the text style. Example code:

import pyTextColor

pytext = pyTextColor.pyTextColor()

text = pytext.format_text(text="I am bold text", color="#ff0000",
                          bgcolor="#FFFF00", text_style="bold")  # bold text

print(text)  # Print the text

The output of the above program will be:

Image 3

There are many text styles you can use! See the list of available styles:

  • normal > for normal text
  • bold > for bold text
  • faint > for faint text
  • italic > for italic text
  • underline > for underlined text
  • blink > for blinking text
  • reverse > for reversed text. The color of the text will be changed to background color while the background color will be changed to text color
  • hidden > for hidden text
  • strikethrough > for strikethrough text

Print the documentation

To pretty print the documentation for this library, run the following code:

import pyTextColor

pytext = pyTextColor.pyTextColor()
pytext.pretty_print_help()  # Print the docs

The output will be:

Image 4

Parameters of the format_text() function

The format_text() function has many parameters such as:

  • text > The text you want
  • color > The color you want
  • bgcolor > The background color you want
  • text_style > The text style you want
  • bg_full_line > Set this to True if you want the background color to be printed on full line

Make output fully customised?

See the following program to make the output fully customized:

import pyTextColor

pytext = pyTextColor.pyTextColor()

color = pytext.color  # Color Function
style = pytext.style  # Style Function
bg = pytext.background  # Background Function
reset = pytext.reset  # Reset Function (To reset all styles/colors/etc.)

name = "Siddhesh"
age = 15
hobby = "programming"

text = f"""{bg("black")}{color("#ffffff")}Hi! I am {color("magenta")}{name}{color("#ffffff")}. I am {color("magenta")}{age}{color("#ffffff")} years old. My favourite hobby is {color("green")}{style("italic")}{hobby}{reset()}"""  # Make an f-string and edit the text

print(text)  # Print the output

The output will be:

Image 5

Remember to use the reset() function or the normal text will be printed out with styles when you print a text below the styled text.

Thank you!

Owner
Siddhesh Chavan
I am a 15 year old boy who loves coding!
Siddhesh Chavan
grungegirl is the hacker's drug encyclopedia. programmed in python for maximum modularity and ease of configuration.

grungegirl. cli-based drug search for girls. welcome. grungegirl is aiming to be the premier drug culture application. it is the hacker's encyclopedia

Eristava 10 Oct 02, 2022
Browse Hacker News like a haxor: A Hacker News command line interface (CLI).

haxor-news Coworker who sees me looking at something in a browser: "Glad you're not busy; I need you to do this, this, this..." Coworker who sees me s

Donne Martin 3.8k Jan 07, 2023
🐍 Python CLI tool to get public information from a GitHub account

🐍 Gitter 🐍 Python CLI tool to get public information from a GitHub account 🤔 What's this? Gitter is a open-source project created to easily uses th

opp? 3 Oct 14, 2022
Projeto Reverse Shell For Python

Use com sabedoria!!! Modo de uso: Linux (inclui Android e Mac): - apt-get update - apt install python3 (ou "python" apenas) - git clone https://github

1 Jan 03, 2022
Command line tool to keep track of your favorite playlists on YouTube and many other places.

Command line tool to keep track of your favorite playlists on YouTube and many other places.

Wolfgang Popp 144 Jan 05, 2023
A handy command-line utility for generating and sending iCalendar events

A handy command-line utility for generating and sending iCalendar events This simple command-line utility is designed to generate an iCalendar event,

Baochun Li 17 Nov 21, 2022
Runs a command in P4wnP1 and displays the output on OLED screen (SH1106)

p4wnp1-oled-terminal Runs a command in P4wnP1 and displays the output on OLED screen (SH1106) Works on Raspberry Pi Zero 2 W Tested successfully on RP

PawnSolo 1 Dec 14, 2021
dotfilery, configuration, environment settings, automation, etc.

┌┬┐┌─┐┌─┐┌─┐┬ ┬┌┬┐┬ ┬┬┌─┐ │││├┤ │ ┬├─┤│ │ │ ├─┤││ :: bits & bobs, dots & things. ┴ ┴└─┘└─┘┴ ┴┴─┘┴ ┴ ┴ ┴┴└─┘ @megalithic 🚀 Instal

Seth Messer 89 Dec 25, 2022
Enlighten Progress Bar is a console progress bar library for Python.

Overview Enlighten Progress Bar is a console progress bar library for Python. The main advantage of Enlighten is it allows writing to stdout and stder

Rockhopper Technologies 265 Dec 28, 2022
A simple Python CLI tool that draws routes/paths on a given map.

Map Router A simple Python CLI tool that draws routes/paths on a given map. Index Installation Usage Docs Why? License Support Installation Coming soo

Pedro Morim 1 Nov 07, 2021
flora-dev-cli (fd-cli) is command line interface software to interact with flora blockchain.

Install git clone https://github.com/Flora-Network/fd-cli.git cd fd-cli python3 -m venv venv source venv/bin/activate pip install -e . --extra-index-u

14 Sep 11, 2022
Investing library and command-line interface inspired by the Bogleheads philosophy

Lakshmi (Screenshot of the lak command in action) Background This project is inspired by Bogleheads forum. Bogleheads focus on a simple but powerful p

Sarvjeet Singh 108 Dec 26, 2022
A CLI tools to get you started on any project in any language

Any Template A faster easier to Quick start any programming project. Installation pip3 install any-template Features No third party dependencies. Tem

Adwaith Rajesh 2 Jan 11, 2022
A simple terminal-based localhost chat application written in python

Chat House A simple terminal-based localhost chat application written in python How to Use? Clone the repo git clone https://github.com/heksadecimal/c

Heks 10 Nov 09, 2021
A Python module and command-line utility for converting .ANS format ANSI art to HTML

ansipants A Python module and command-line utility for converting .ANS format ANSI art to HTML. Installation pip install ansipants Command-line usage

4 Oct 16, 2022
MiShell is a multi-platform, multi-architecture project based on the first version (MiShell32)

MiShell is a multi-platform, multi-architecture project based on the first version (MiShell32), which offers super super small reverse shell payloads great for injection in buffer overflow vulnerabil

Kamyar Hatamnezhad 0 Oct 27, 2022
inklayers is a command line program that exports layers from an SVG file.

inklayers is a command line program that exports layers from an SVG file. It can be used to create slide shows by editing a single SVG file.

11 Mar 29, 2022
Commandline Python app to Autodownload mediafire folders and files.

Commandline Python app to Autodownload mediafire folders and files.

Tharuk Renuja 3 May 12, 2022
ghfetch is ai customizable CLI GitHub personal README generator.

ghfetch is ai customizable CLI GitHub personal README generator. Inspired by famous fetch such as screenfetch, neofetch and ufetch, the purpose of this tool is to introduce yourself as if you were a

Alessio Celentano 3 Sep 10, 2021
Bryce Geiser 4 Aug 04, 2022