Skip to main content

A simple package to wrap text with ASCII art

Project description

Text Box Wrapper

A simple Python package to wrap text with ASCII art or other characters. It also supports custom alignment (left, center, or right) and can be used as a decorator.

Installation

Install the package using pip:

pip install text-box-wrapper

Usage

Basic usage

Import the wrap_with_ascii_art function and use it to wrap your text:

from text_box_wrapper import wrap_with_ascii_art

text = "Hello, World!"
wrapped_text = wrap_with_ascii_art(text)
print(wrapped_text)

Example output:

###########################################
###########################################
#####                                 #####
#####                                 #####
#####          Hello, World!          #####
#####                                 #####
#####                                 #####
###########################################
###########################################

Customizing the wrapper

You can customize the padding, border string, and alignment:

from text_box_wrapper import wrap_with_ascii_art

text = "你好,成都"
border_string = "#"
wrapped_text = wrap_with_ascii_art(text, min_padding=5, vertical_padding=2, border_string=border_string, alignment="center")
print(wrapped_text)

Example output:

######################
#                    #
#                    #
#     你好,成都       #
#                    #
#                    #
######################

Using the decorator

You can also use the wrap decorator to automatically wrap the output of a function:

from text_box_wrapper import wrap

@wrap(min_padding=7, vertical_padding=1, border_string="*", alignment="center")
def greet(name):
    return f"Hello, {name}!"

print(greet("John"))

Example output:

****************************
*                          *
*       Hello, John!       *
*                          *
****************************

Contributing

Feel free to submit issues or pull requests if you have any suggestions, improvements, or bug reports.

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

text-box-wrapper-0.1.5.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

text_box_wrapper-0.1.5-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file text-box-wrapper-0.1.5.tar.gz.

File metadata

  • Download URL: text-box-wrapper-0.1.5.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for text-box-wrapper-0.1.5.tar.gz
Algorithm Hash digest
SHA256 4443678cd7bfb06dee4d3a243ce73e2adba07570f660369a5634d6966c5daf18
MD5 44af761c53ece0676a2578a01b65f307
BLAKE2b-256 d9df725c690894e9815b883ed8be5fc546c99ceafd38e33dedc3adc7a53ab802

See more details on using hashes here.

File details

Details for the file text_box_wrapper-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for text_box_wrapper-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 675b55073b0caa7475369880a74716f132d6fe0cbbf845f336f449a44807c414
MD5 9b70772e160c6d7b9b8f9a2ea9de0735
BLAKE2b-256 bf1a427543360edc9bbb3831fa589857cf2cd2930296055c2dd610099a49c636

See more details on using hashes here.

Supported by

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