a Python engine to print out colorful text in the terminal
This library is only compatible with windows.
This library will install Colorama, too.
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!
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.
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.
Colorful().reset()
Parameters
(param: Literal["t", "b", "s", "a", "tb", "ts", "bs"])
Same reset parameters as Colorful() class initialization. (Except for False option)
def __str__()
returns a description of the Colorful engine:
"Text Engine with autoreset mode (your reset mode and details)."
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
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
def __str__()
returns a description of the font:
"(style) (foreground) text in (background) background."
-> 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.
-> 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.
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!