A small package for printing boxes
Project description
Boxprint
A small package to print boxes
Usage
from boxprint import bprint
bprint("hello world")
╭──────────────────────────────────────────────────────────────────────────────╮
│ Hello World │
╰──────────────────────────────────────────────────────────────────────────────╯
Examples
Simple Usage
from boxprint import bprint, BoxTypes
"""
@param width
Max width of the box
@param box_type
The type of the box (LIGHT, HEAVY, DOUBLE, ROUND)
@param print_func
The print function to use
"""
bprint("hello_world", width=40, box_type=BoxTypes.HEAVY, print_func=print)
bprint("Text\nWith\nMultiple\nLines")
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Hello World ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
╭──────────────────────────────────────────────────────────────────────────────╮
│ Text │
│ With │
│ Multiple │
│ Lines │
╰──────────────────────────────────────────────────────────────────────────────╯
Nested Boxes
buf = []
def print_to_buf(string):
buf.append(string)
# Boxes apply 2 spaces of padding to the left and right width = (default=80 - 2*2)
bprint("Inner Box", width=76, print_func=print_to_buf)
inner_box = "".join(buf)
bprint(f"I am some text!\n{inner_box}", title="Outer Box")
╭─┤ Outer Box ├────────────────────────────────────────────────────────────────╮
│ │
│ I am some text! │
│ ╭──────────────────────────────────────────────────────────────────────────╮ │
│ │ Inner Box │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯
Solid Box
from colors import * # ansicolors
bprint(
"\nhello_world\n",
width=40,
box_type=BoxTypes.FILL,
stroke_func=lambda text: color(text, fg="blue"),
fill_func=lambda text: color(text, bg="blue", fg="black")
)
▗▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▖
▐ ▌
▐ hello_world ▌
▐ ▌
▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▘
Debug
from boxprint.dprint import dprint
a_list_of_numbers = [1, 2, 3, 4, 5]
dprint(a_list_of_numbers)
a_list_of_numbers = None
dprint(a_list_of_numbers)
╭─┤ a_list_of_numbers ├────────────────────────────────────────────────────────╮
│ │
│ tests/test_debug.py:11 │
│ │
│ type = <class 'list'> │
│ value = [1, 2, 3, 4, 5] │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─┤ a_list_of_numbers ├────────────────────────────────────────────────────────╮
│ │
│ tests/test_debug.py:14 │
│ │
│ type = <class 'NoneType'> │
│ value = None │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
Current Stack
from boxprint.stprint import stprint
def my_function(param1, param2):
local1 = [param1] * 4
local2 = "a"
stprint(width=60)
for i in range(5):
my_function(i, i*3)
╭─┤ my_function - tests/test_stprint.py:35 ├───────────────╮
│ │
│ param1 = 0 │
│ param2 = 0 │
│ local1 = [0, 0, 0, 0] │
│ local2 = a │
│ │
╰──────────────────────────────────────────────────────────╯
╭─┤ my_function - tests/test_stprint.py:35 ├───────────────╮
│ │
│ param1 = 1 │
│ param2 = 3 │
│ local1 = [1, 1, 1, 1] │
│ local2 = a │
│ │
╰──────────────────────────────────────────────────────────╯
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
boxprint-0.0.13.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for boxprint-0.0.13-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af7ce5e2447c4ceff7cd79c7900d4a5c00e00d9900cc89f50c7921c592bba1b6 |
|
MD5 | ffbf467d4ed559c9a50faff653918024 |
|
BLAKE2b-256 | 2fd0ff828e6363cc8007fd9ceeb210b5fe74b817f8a9587235d7714808daf363 |