Skip to main content

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
from colors import *  # ansicolors

"""
@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
@param stroke_func
  How the box characters should be stroked
@param fill_func
  How the text characters should be filled
"""
bprint("hello_world", width=40, box_type=BoxTypes.HEAVY, print_func=print)
bprint("Text\nWith\nMultiple\nLines")
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")
)

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")
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Hello World                          ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

╭──────────────────────────────────────────────────────────────────────────────╮
│ Text                                                                         │
│ With                                                                         │
│ Multiple                                                                     │
│ Lines                                                                        │
╰──────────────────────────────────────────────────────────────────────────────╯

▗▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▖
▐                                      ▌
▐ hello_world                          ▌
▐                                      ▌
▝▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▘

╭─┤ Outer Box ├────────────────────────────────────────────────────────────────╮
│                                                                              │
│ I am some text!                                                              │
│ ╭──────────────────────────────────────────────────────────────────────────╮ │
│ │ Inner Box                                                                │ │
│ ╰──────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────╯

Debug

from boxprint 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 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


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.15.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

boxprint-0.0.15-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file boxprint-0.0.15.tar.gz.

File metadata

  • Download URL: boxprint-0.0.15.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.0

File hashes

Hashes for boxprint-0.0.15.tar.gz
Algorithm Hash digest
SHA256 4672f8236f948d0a3d4e2ba144990465f4fe4016a9d9ebb3ae2530d956459471
MD5 49391fdb8c70a3026f147db2572f175c
BLAKE2b-256 91d064830c5200b594fca801f0dcec5471571fd2e4889a19f331eb099640306f

See more details on using hashes here.

File details

Details for the file boxprint-0.0.15-py3-none-any.whl.

File metadata

  • Download URL: boxprint-0.0.15-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.0

File hashes

Hashes for boxprint-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 c5923442ef0383a73414f278d80de151a0bcdc77cbe09c168706c0a82fd2e4c1
MD5 4f9cc568e81182d3644b8d3eae8a3754
BLAKE2b-256 82d39e085c1b5201aa869c5257aea42e5deb9815cc8db9cad622d28f6c8d5fe1

See more details on using hashes here.

Supported by

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