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
Python Processing Tool for Vasp Ipnut/Output

PivotPy A Python Processing Tool for Vasp Input/Output. A CLI is available in Powershell, see Vasp2Visual. stylea{text-decoration: none !important;c

Abdul Saboor 5 Aug 16, 2022
Stephen's Obsessive Note-Storage Engine.

Latest Release · PyPi Package · Issues · Changelog · License # Get Sonse and tell it where your notes are... $ pip install sonse $ export SONSE="$HOME

Stephen Malone 23 Jun 10, 2022
Baseline is a cross-platform library and command-line utility that creates file-oriented baselines of your systems.

Baselining, on steroids! Baseline is a cross-platform library and command-line utility that creates file-oriented baselines of your systems. The proje

Nelson 4 Dec 09, 2022
Darkdump - Search The Deep Web Straight From Your Terminal

Darkdump - Search The Deep Web Straight From Your Terminal About Darkdump Darkdump is a simple script written in Python3.9 in which it allows users to

Josh Schiavone 264 Dec 30, 2022
texel - Command line interface for reading spreadsheets inside terminal

texel - Command line interface for reading spreadsheets inside terminal. Sometimes, you have to deal with spreadsheets. Those are sad times. Fortunate

128 Dec 19, 2022
Amazon Scraper: A command-line tool for scraping Amazon product data

Amazon Product Scraper: 2021 Description A command-line tool for scraping Amazon product data to CSV or JSON format(s). Requirements Python 3 pip3 Ins

49 Nov 15, 2021
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
Konsave lets use save your KDE Plasma customizatios and restore them very easily!

Konsave (Save Plasma Customization) A CLI program that will let you save and apply your KDE Plasma customizations with just one command! Als

439 Jan 02, 2023
Convert shellcode generated using pe_2_shellcode to cdb format.

pe2shc-to-cdb This tool will convert shellcode generated using pe_to_shellcode to cdb format. Cdb.exe is a LOLBIN which can help evade detection & app

mrd0x 75 Jan 05, 2023
A terminal tool for git. When we use git, do you feel very uncomfortable with too long commands

PIGIT A terminal tool for git. When we use git, do you feel very uncomfortable with too long commands. For example: git status --short, this project c

Zachary 1 Apr 09, 2022
A command-line tool to upload local files and pastebin pastes to your mega account, without signing in anywhere

A command-line tool to upload local files and pastebin pastes to your mega account, without signing in anywhere

ADI 4 Nov 17, 2022
A Telegram Bot Written In Python To Upload Medias To telegra.ph

Telegraph-Uploader A Telegram Bot Written In Python To Upload Medias To telegra.ph DEPLOY YOU CAN SIMPLY DEPLOY ON HEROKU BY CLICKING THE BUTTON BELOW

Rithunand 31 Dec 03, 2022
Lets you view, edit and execute Jupyter Notebooks in the terminal.

Lets you view, edit and execute Jupyter Notebooks in the terminal.

David Brochart 684 Dec 28, 2022
Pastekan adalah website paste kode / teks sederhana

Pastekan pastekan adalah website paste kode / teks sederhana. install pip install pastekan penggunaan pastekan myfile.txt atau echo "hi" | pastekan

Sekai Kode 1 Dec 24, 2021
CLI client for RFC 4226's HOTP and RFC 6238's TOTP.

One Time Password (OTP, TOTP/HOTP) OTP serves as additional protection in case of password leaks. onetimepass allows you to manage OTP codes and gener

Apptension 4 Jan 05, 2022
alternative cli util for update-alternatives

altb altb is a cli utility influenced by update-alternatives of ubuntu. Linked paths are added to $HOME/.local/bin according to XDG Base Directory Spe

Elran Shefer 8 Dec 07, 2022
CPOST is a CLI tool to assist with the proper sizing of Clara Deploy pipelines

CPOST (Clara Pipeline Operator Sizing Tool) Tool to measure resource usage of Clara Platform pipeline operators Cpost is a tool that will help you run

NVIDIA Corporation 5 Sep 27, 2021
f90nml - A Fortran namelist parser, generator, and editor

f90nml - A Fortran namelist parser, generator, and editor A Python module and command line tool for parsing Fortran namelist files Documentation The c

Marshall Ward 110 Dec 14, 2022
PyArmor is a command line tool used to obfuscate python scripts

PyArmor is a command line tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.

Dashingsoft 2k Jan 07, 2023
An easy-to-bundle GTK terminal emulator.

EasyTerm An easy-to-bundle GTK terminal emulator. This project is meant to be used as a dependency for other

Bottles 4 May 15, 2022