"ASCII art" boxes in Python
Find a file
2025-08-07 20:56:12 +03:00
.gitignore First commit 2025-07-26 21:56:51 +03:00
boxes.py Allow specifying which borders to include in Box.frame() 2025-08-07 20:56:12 +03:00
CC0 First commit 2025-07-26 21:56:51 +03:00
layout.py Add support for expanding BorderBoxes with padding inside the borders 2025-08-07 00:17:37 +03:00
README.md Add support for laying out BorderBoxes too 2025-07-27 00:18:43 +03:00

Laatikoita

Laatikoita (Finnish for 'boxes') is a collection of simple one-file libraries for creating and working with "ASCII art" boxes in Python. It implements an interface in the style of Box combinators, but also has support for boxes that have collapsible borders.

Examples

>>> from boxes import from_string as S
>>> S('hello').print()
hello
>>> S('hello').above(S('world')).print()
hello
world
>>> S('hello').above(S('world')).frame().above(S('boxes').frame()).print()
┌─────┐
hello
world
├─────┤
boxes
└─────┘
>>> from layout import stack, lay
>>> stack(map(S, 'split across several lines'.split())).print()
split  
across 
several
lines  
>>> from boxes import box
>>> lay([box(1, 0).frame().to_box(), box(0, 1).frame().to_box()]).print()
┌─┐┌┐
└─┘││
   └┘
>>> from layout import align_bottom
>>> lay([box(1, 0).frame().to_box(), box(0, 1).frame().to_box()], align_bottom).print()
   ┌┐
┌─┐││
└─┘└┘
>>> lay([stack([S('possible to'), S('lay out')]).frame(), S('frames too').frame()]).print()
┌───────────┬──────────┐
possible toframes too
lay out    ├──────────┘
└───────────┘

Documentation

At the moment laatikoita is only really documented using the docstrings.

License

Laatikoita is free software under the terms of Creative Commons Zero 1.0 Universal ("CC0").