Skip to main content

Beginner-friendly library for colored terminal outputs.

Project description

ColorfulEngine

a Python engine to print out colorful text in the terminal

Important

This library is only compatible with windows.
This library will install Colorama, too.

Quickstart

The library consists of two classes.
One for the log engine, and another for fonts.

You can also use our ColofulError exceptions and FontError exceptions to your own will.

This library supports anything the terminal supports!

Colorful Class

Initializing

Parameters:
(autoreset: Literal["t", "b", "s", "a"] | Literal[False] = False) -> Colorful
autoreset parameter -> How you want the engine to autoreset everytime after printing to console.

Options Explanation:
t -> Reset text color.
b -> Reset background.
s -> Reset text brightness (style).
Combine the above for custom resets.
E.g. tb -> Reset text color & background.
a -> Reset everything.
False (bool) -> Disable resetting.

Log Text

Colorful().log() Parameters
(text: str = "Hello, world.", font: Font = Font()) -> str
text parameter -> The text you want to print.
font parameter -> The style you want to use.
font parameter requires a Font() class. Default is -> new Font()

Returns the text you just printed.

Reset Console

Colorful().reset()
Parameters
(param: Literal["t", "b", "s", "a", "tb", "ts", "bs"])
Same reset parameters as Colorful() class initialization. (Except for False option)

str(Colorful())

def __str__()
returns a description of the Colorful engine: "Text Engine with autoreset mode (your reset mode and details)."

Font Class

Initializing

Parameters:
(foreground: str = 'WHITE', background: str = 'BLACK', styling: str = 'NORMAL')
foreground parameter -> font text color
background parameter -> font bg color
srtling parameter -> font brightness

Options Explanation:
Parameters are NOT case-sensitive.
For Background & Foreground:

  • BLACK
  • RED
  • GREEN
  • YELLOW
  • BLUE
  • MAGENTA
  • CYAN
  • WHITE
  • LIGHTBLACK
  • LIGHTRED
  • LIGHTGREEN
  • LIGHTYELLOW
  • LIGHTBLUE
  • LIGHTMAGENTA
  • LIGHTCYAN
  • LIGHTWHITE

For Styling:

  • DIM
  • NORMAL
  • BRIGHT

Change Properties

Font().changeFore() foreground parameter -> new foreground to change to

returns -> new Font() and updates the old Font()

Font().changeBack() background parameter -> new background to change to

Font().restyle() style parameter -> new brightness to change to

str(Font())

def __str__()
returns a description of the font:
"(style) (foreground) text in (background) background."

Exceptions

ColorfulError

-> Errors that occured in the Coloful class.
When will it occur:

  • When you initialize a Colorful class with autoreset True. Reason -> Confuses computer to not know which autoreset mode?
  • When you initiliaze a Colorful class with not supported autoreset types.
  • Manually resetting a Coloful engine console while not specifying the autoreset mode correctly.

FontError

-> Erros that occured in the Font class.
When will it occur:

  • When you are not setting a str value for Font class initialization parameters.
  • When you are changing the foreground, background, or brightness (style) to an unsupported value.

Code Example

from __init__ import Colorful, Font

engine = Colorful("tb") # autoreset text and background
engine.log(engine) # Text Engine with autoreset mode "tb" for autoresetting text and background colors.
font1 = Font(foreground="CYAN", styling="BRIGHT") # bright, cyan font

engine.log(text="Hello, world!", font=font1) # (cyan, bright) Hello, world!
# font1 resets text and background
font1.changeBack("BLUE") # change background to blue
font1.changeFore("WHITE") # change foreground to white
# support for Chinese, Korean, Japanese and a lot more!
engine.log(text="哇! 好酷喔!", font=font1) # (white, bright) 哇! 好酷喔! (blue)
# font1 resets text and background
font1.changeBack("MAGENTA") # change background to blue
font1.changeFore("BLACK") # change foreground to white
engine.log(text="안녕하세요", font=font1) # (black, bright) 안녕하세요 (magenta)
# font1 resets text and background
engine.log(font1) # Bright White text in Black background.

engine.reset("a") # Resets the console if you want to use print normally
print("Normal text!") # Normal text!

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

colorfulengine-1.0.2.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

colorfulengine-1.0.2-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file colorfulengine-1.0.2.tar.gz.

File metadata

  • Download URL: colorfulengine-1.0.2.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for colorfulengine-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e210f1313acfbf62a0db8a72b0e45f4cdb108eb21a0c03aee7e9e1f4cca0dca3
MD5 0e1af5a6e45bb4acf7d917611f33d144
BLAKE2b-256 a0faa519cd5287c5307d5d90b330f99a43674557b8aebaa1ca25ac6a2965c2b5

See more details on using hashes here.

File details

Details for the file colorfulengine-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: colorfulengine-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for colorfulengine-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 de6d134ceca681d37d6331bae83d432cb45b5bc87a54136bc4be2c8c7476acf8
MD5 41a8eb1cc876d9ee2dfc2d0e9fd14c8d
BLAKE2b-256 223800d0f002cd68cb57e8cf644d7455259ded464cd1c42ee838928813e3d57d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page