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.
Install the package using pip:
pip install text-box-wrapper
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)
###########################################
###########################################
##### #####
##### #####
##### Hello, World! #####
##### #####
##### #####
###########################################
###########################################
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)
######################
# #
# #
# 你好,成都 #
# #
# #
######################
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"))
****************************
* *
* Hello, John! *
* *
****************************
Feel free to submit issues or pull requests if you have any suggestions, improvements, or bug reports.
This project is licensed under the MIT License.