Skip to main content

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/) License: MIT

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

easyascii_py-1.0.2.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easyascii_py-1.0.2-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

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

Hashes for easyascii_py-1.0.2.tar.gz
Algorithm Hash digest
SHA256 63831f22fb2493e66057605f404b5eaa830cd3e2d42161ff02d7da0e17552d2a
MD5 b7bd0623e28819e78d62231fcb5fc8bd
BLAKE2b-256 ea5a1ec3daa657dd5977243a55bda6455808d6a937906b6fafb11e16aab5bb57

See more details on using hashes here.

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

Hashes for easyascii_py-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2de302d0b7d86f205589599b85446dc8d6e41de1cbd831672313b0a8c04dbeba
MD5 739397df088ff03b2d73444271a565bb
BLAKE2b-256 2b248671f1f46686466e329fa10c6f9076bc6a61ecb57c2de508088e8d2ec760

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page