A simple, zero-dependency library for creating ASCII art and console UIs.
Project description
Easy ASCII
A comprehensive, single-file, zero-dependency Python library for creating beautiful and functional text-based user interfaces and ASCII art.
[![PyPI version] (https://pypi.org/project/easyascii-py/1.0.2/)
Easy ASCII is designed to be incredibly simple to use while providing a powerful set of tools for command-line applications. Whether you need to display data in a clean table, create an eye-catching banner, or show progress for a long-running task, this library has you covered.
โจ Key Features
-
๐ฆ Advanced Boxes: Create boxes with multiple border styles, titles, and text alignment.
-
๐ Data Tables: Generate perfectly formatted tables from lists of dictionaries with text wrapping.
-
๐ ฐ๏ธ FIGlet Banners: Render large ASCII text banners with a built-in font.
-
โณ Progress Bars & Spinners: Provide user feedback for long-running tasks.
-
๐ณ Tree Structures: Visualize hierarchical data like file systems.
-
๐๏ธ Multi-Column Layouts: Arrange text into clean, evenly spaced columns.
-
๐ Lists & Rules: Create ordered/unordered lists and customizable horizontal rules.
-
๐ Pure Python: Single file with zero external dependencies.
-
๐ก Developer Friendly: Fully type-hinted with extensive docstrings and a flexible API.
๐ฆ Installation
Install easyascii directly from PyPI:
pip install easyascii-py==1.0.2
๐ Quick Start
Creating a rich console output is simple. Just import the functions you need and call them.
import easyascii
1. Create a banner for your application
easyascii.print_banner("My App")
2. Create a styled box for a welcome message
easyascii.print_box( "Welcome to my awesome application!\nHere is some important information.", title="Info", style="rounded" )
3. Display data in a table
user_data = [
{"ID": 1, "Username": "alex", "Status": "Active"},
{"ID": 2, "Username": "brian_the_dev", "Status": "Active"},
{"ID": 3, "Username": "casey", "Status": "Inactive"},
]
easyascii.print_table(user_data, style="double", align={"ID": "center"})
Output:
# # # # ### #### ####
## ## # # # # # # # #
# # # # ##### #### ####
# # # # # # #
# # # # # # #
โญโโโโโโโโโโโโโโโโ Info โโโโโโโโโโโโโโโโโโฎ
โ Welcome to my awesome application! โ
โ Here is some important information. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โโโโโโฆโโโโโโโโโโโโโโโโฆโโโโโโโโโโโ
โ ID โ Username โ Status โ
โ โโโโโฌโโโโโโโโโโโโโโโโฌโโโโโโโโโโโฃ
โ 1 โ alex โ Active โ
โ 2 โ brian_the_dev โ Active โ
โ 3 โ casey โ Inactive โ
โโโโโโฉโโโโโโโโโโโโโโโโฉโโโโโโโโโโโ
๐ API Reference Convenience print_* Wrappers
Display Functions
box()
table()
banner()
hr()
listing()
columns()
tree()
Dynamic UI Functions
progress_bar()
Spinner
Convenience print_
For every function that returns a string (like box, table, etc.), there is a corresponding "print_" version (e.g., print_box) that prints the result directly to the console. The "print_" versions accept the exact same arguments.
Display Functions
box()
Creates a string of text inside an ASCII box.
Signature:
def box(
text: Any,
style: str = "light",
width: Optional[int] = None,
title: str = "",
align: str = "left",
padding: Union[int, Tuple[int, int]] = 1
) -> str
Parameters:
text (Any): The text content to display. Can be multi-line.
style (str): The border style. Available: "light", "heavy", "double", "rounded", "star", "hash", "plus".
width (Optional[int]): Total width of the box. Auto-calculated if None.
title (str): An optional title to display on the top border.
align (str): Text alignment ("left", "center", "right").
padding (Union[int, Tuple[int, int]]): Horizontal and vertical padding. E.g., 1 or (2, 1).
Example:
message = "This box is centered and has a heavy border style with custom padding."
print(easyascii.box(message, style="heavy", title="Attention", align="center", padding=(4, 1), width=70))
Output:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Attention โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ This box is centered and has a heavy border style โ
โ with custom padding. โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
table()
Creates a formatted ASCII table from a list of dictionaries. Signature:
def table(
data: List[Dict[str, Any]],
headers: Optional[List[str]] = None,
style: str = "light",
align: Union[str, Dict[str, str]] = "left",
max_col_width: Optional[int] = None
) -> str
Parameters:
data (List[Dict]): A list of dictionaries, where each dict is a row.
headers (Optional[List[str]]): A list of header keys. If None, uses keys from the first row.
style (str): The border style (see box() for options).
align (Union[str, Dict]): Default alignment, or a dictionary mapping header keys to alignments.
max_col_width (Optional[int]): Maximum width for any single column (enables text wrapping).
Example:
data = [
{"File": "main.py", "Size (KB)": 12.5, "Last Modified": "2023-10-27"},
{"File": "utils/helpers.py", "Size (KB)": 34.1, "Last Modified": "2023-10-26"},
{"File": "README.md", "Size (KB)": 2.8, "Last Modified": "2023-10-27"},
]
print(easyascii.table(data, style="light", align={"Size (KB)": "right"}))
Output:
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ
โ File โ Size (KB) โ Last Modified โ
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโค
โ main.py โ 12.5 โ 2023-10-27 โ
โ utils/helpers.py โ 34.1 โ 2023-10-26 โ
โ README.md โ 2.8 โ 2023-10-27 โ
โโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
banner()
Renders large ASCII text.
Signature:
def banner(text: str) -> str
Example:
print(easyascii.banner("Ready!"))
Output:
#### ##### ### #### # # #
# # # # # # # # # #
#### ### ##### # # # #
# # # # # # # #
# # ##### # # #### # #
hr()
Creates a horizontal rule (a line separator).
Signature:
def hr(width: Optional[int] = None, char: str = "-", title: str = "") -> str
Example:
print(easyascii.hr(width=50, char="=", title="Section Break"))
Output:
================= Section Break ==================
listing()
Formats an iterable into an ordered or unordered list.
Signature:
def listing(items: Iterable[Any], ordered: bool = False, indent: int = 2) -> str
Example:
tasks = ["Design UI", "Implement backend", "Write tests"]
print("Todo List:")
print(easyascii.listing(tasks, ordered=True, indent=4))
Output:
Todo List:
1. Design UI
2. Implement backend
3. Write tests
columns()
Arranges a list of strings into multiple columns. Signature:
def columns(texts: List[str], num_cols: int = 2, spacing: int = 4) -> str
Example:
items = ["Apple", "Banana", "Cherry", "Date", "Elderberry", "Fig", "Grape"]
print(easyascii.columns(items, num_cols=3, width=50))
Output:
Apple Elderberry
Banana Fig
Cherry Grape
Date
tree()
Generates an ASCII tree structure from a nested dictionary.
Signature:
def tree(data: Dict[str, Any]) -> str
Example:
file_system = {
"project/": {
"src/": {
"main.py": None,
"utils.py": None
},
"README.md": None
}
}
print(easyascii.tree(file_system))
Output:
โโโ project/
โโโ src/
โ โโโ main.py
โ โโโ utils.py
โโโ README.md
Dynamic UI Functions
progress_bar()
Prints a dynamic, single-line progress bar. Should be called inside a loop. Signature:
def progress_bar(
iteration: int,
total: int,
prefix: str = 'Progress:',
suffix: str = 'Complete',
length: int = 50,
fill: str = 'โ'
)
Example:
import time
import easyascii
total_items = 200
for i in range(total_items + 1):
easyascii.progress_bar(i, total_items, prefix='Processing:', suffix='Done')
time.sleep(0.01)
Output (at the end of the loop):
Processing: |โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 100.0% Done
Spinner
A context manager for displaying a loading spinner for long operations. Signature:
class Spinner:
def __init__(self, text: str = "Loading...", style: str = "dots", delay: float = 0.1)
style (str): The spinner animation style. Available: "dots", "line", "arrow", "box".
Example:
import time
import easyascii
with easyascii.Spinner("Fetching data from API...", style="arrow"):
time.sleep(3)
print("Data fetched successfully!")
Output (during execution):
Fetching data from API... โ (character rotates)
Output (after completion):
Data fetched successfully!
๐ค Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
๐ License
This project is licensed under the MIT License.
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
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 easyascii_py-1.0.2.tar.gz.
File metadata
- Download URL: easyascii_py-1.0.2.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63831f22fb2493e66057605f404b5eaa830cd3e2d42161ff02d7da0e17552d2a
|
|
| MD5 |
b7bd0623e28819e78d62231fcb5fc8bd
|
|
| BLAKE2b-256 |
ea5a1ec3daa657dd5977243a55bda6455808d6a937906b6fafb11e16aab5bb57
|
File details
Details for the file easyascii_py-1.0.2-py3-none-any.whl.
File metadata
- Download URL: easyascii_py-1.0.2-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2de302d0b7d86f205589599b85446dc8d6e41de1cbd831672313b0a8c04dbeba
|
|
| MD5 |
739397df088ff03b2d73444271a565bb
|
|
| BLAKE2b-256 |
2b248671f1f46686466e329fa10c6f9076bc6a61ecb57c2de508088e8d2ec760
|