Fancy terminal message box renderer using Unicode box characters and ANSI styling.
Uses a dynamic string buffer for quick and snappy message rendering.
pip install sysmess
-
Clone the repository
git clone https://github.com/canadaluke888/sysmess.git
-
Build the extension in-place:
python3 setup.py build
(MacOS & Linux)python setup.py build
(Windows) -
(Optional) Install into your current environment:
-
Make a virtual environment:
python3 -m venv .venv
(MacOS & Linux) |python -m venv .venv
(Windows) -
Activate virtual environment:
source .venv/bin/activate
(MacOS & Linux) |.venv/Scripts/Activate
(Windows) -
Install into current environment:
pip install .
-
import sysmess
msg = sysmess.fancy_box(
"Hello, world!",
title="Greeting",
center=True,
bold=True,
italic=False,
)
print(msg)
# Measure the width of the box (including borders)
width = sysmess.measure_box_width("Hello, world!", title="Greeting")
print(width)
msg = sysmess.fancy_box(
"Rounded corners!",
title="Round",
style="round"
)
print(msg)
You can also specify colors for the border, title, and body:
msg = sysmess.fancy_box(
"Colored message",
title="Colorful",
border_color="magenta",
title_color="cyan",
body_color="yellow"
)
print(msg)
Supported color names:
Basic colors | Bright colors |
---|---|
black | bright_black |
red | bright_red |
green | bright_green |
yellow | bright_yellow |
blue | bright_blue |
magenta | bright_magenta |
cyan | bright_cyan |
white | bright_white |
By passing wrap=True
, sysmess will wrap your message text to fit your terminal width (or a specific maximum width via max_width
):
import sysmess
long_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit..."
print(sysmess.fancy_box(long_text, wrap=True))
# Or specify a fixed max width:
print(sysmess.fancy_box(long_text, wrap=True, max_width=60))
You can make the border, title, or body text blink using the blink flags:
import sysmess
print(sysmess.fancy_box("Blinking border!", blink_border=True))
print(sysmess.fancy_box("Blinking title!", title="Hey", blink_title=True))
print(sysmess.fancy_box("Blinking body text!", blink_body=True))
Once built (or installed), run the demonstration script to see sample outputs:
python3 examples.py
Run the unit tests using the included test runner:
python3 test.py