Skip to content

Easy Terminal

py_simple.easy_terminal

easy_terminal is meant to make it easy to get styled output in the terminal. Built on top of the rich library — no more memorizing markup strings.

EasyTerminal

Builds styled terminal text by chaining style methods, then prints it.

Nothing is printed until show() is called, so you can chain as many styles as you like first. Every set_* method returns the object itself, which is what makes the chaining work.

Parameters:

Name Type Description Default
text str

The text to print.

required
Example
from py_simple import EasyTerminal

EasyTerminal("Hello World").set_color("red").set_bold().show()
from rich.console import Console

console = Console()
console.print("Hello World", style="bold red")

set_bg_color(color)

Sets the background color and returns the object for chaining.

Parameters:

Name Type Description Default
color str

A color name ("blue"), a hex code ("#0000ff"), or an rgb string ("rgb(0,0,255)").

required

Returns:

Name Type Description
EasyTerminal EasyTerminal

The same object, ready for the next call.

Example
from py_simple import EasyTerminal

EasyTerminal("Hello").set_color("white").set_bg_color("blue").show()
from rich.console import Console

console = Console()
console.print("Hello", style="white on blue")

set_bold()

Makes the text bold and returns the object for chaining.

Replaces any weight set earlier, so calling set_bold() after set_light_weight() leaves the text bold, not both.

Returns:

Name Type Description
EasyTerminal EasyTerminal

The same object, ready for the next call.

Example
from py_simple import EasyTerminal

EasyTerminal("Hello").set_bold().show()
from rich.console import Console

console = Console()
console.print("Hello", style="bold")

set_color(color)

Sets the text color and returns the object so you can keep chaining.

Parameters:

Name Type Description Default
color str

A color name ("red"), a hex code ("#ff0000"), or an rgb string ("rgb(255,0,0)").

required

Returns:

Name Type Description
EasyTerminal EasyTerminal

The same object, ready for the next call.

Example
from py_simple import EasyTerminal

EasyTerminal("Hello").set_color("#ff0000").show()
from rich.console import Console

console = Console()
console.print("Hello", style="#ff0000")

set_light_weight()

Makes the text dim (lighter than normal) and returns the object.

Terminals only have bold, normal and dim, so this is the lightest weight available. It replaces any weight set earlier.

Returns:

Name Type Description
EasyTerminal EasyTerminal

The same object, ready for the next call.

Example
from py_simple import EasyTerminal

EasyTerminal("Hello").set_light_weight().show()
from rich.console import Console

console = Console()
console.print("Hello", style="dim")

show()

Prints the text to the terminal with all the chosen styles.

Call this last. Anything you didn't set falls back to the terminal's normal look (the text color defaults to white).

Example
from py_simple import EasyTerminal

EasyTerminal("Hello World").set_color("red").set_bg_color("white").set_bold().show()
from rich.console import Console

console = Console()
console.print("Hello World", style="bold red on white")