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:
BLACKREDGREENYELLOWBLUEMAGENTACYANWHITELIGHTBLACKLIGHTREDLIGHTGREENLIGHTYELLOWLIGHTBLUELIGHTMAGENTALIGHTCYANLIGHTWHITE
For Styling:
DIMNORMALBRIGHT
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
Colorfulclass with autoresetTrue. Reason -> Confuses computer to not know which autoreset mode? - When you initiliaze a
Colorfulclass with not supported autoreset types. - Manually resetting a
Colofulengine 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
strvalue forFontclass 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file colorfulengine-1.0.0.tar.gz.
File metadata
- Download URL: colorfulengine-1.0.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1fb84c27756db3c6cfef2936b29473ec7c732628447e8e2e9c789bf2a302cde
|
|
| MD5 |
17debf41f1295c36989dd2cdeaf74563
|
|
| BLAKE2b-256 |
bac97b2e11b40797635ffcb9d02be87946e910266577a3b0b04dacd08eb5302a
|
File details
Details for the file colorfulengine-1.0.0-py3-none-any.whl.
File metadata
- Download URL: colorfulengine-1.0.0-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28de60ebf30a823e611dba11ad301fc0580bfc4a1631714f4311131c17d8fbe4
|
|
| MD5 |
b447fdb6e0fb30e712c5d0b6fc996a01
|
|
| BLAKE2b-256 |
7bf59907219e9b5dccbdd830b0c6436ce8f1c1cae1aab50b4167e8035c95b0f4
|