A python library for printing framed text to the terminal.
Project description
This is yet another python library for creating frames around your terminal output.
It creates a frame around text, wrapping the text to fit into the frame.
The implementation follows clean code principles such as single responsibility principle, and dependency injection.
Install
pip install hemline
Use
from hemline import Frame
frame = Frame()
text = "This is some text"
framed = frame.format(text)
Formatting the Frame
You can pass the following parameters to the constructor
ofhemline.Frame:
+ `outer_width` (the width of the frame including `horizontal_padding`),
+ `container_width` (defaults to the width of the terminal),
+ `text_alignment` (either `"center"` or `"left"`),
+ `frame_alignment` inside the container (either `"center"` or `"left"`),
+ `horizontal_padding`,
+ `vertical_padding`
+ `color`
Styling the Frame
Predefined Themes
The characters defining the edges and corners of the frame make a theme. There are four predefined themes, with self-explanatory names:
+ `hemline.themes.single` (The default theme)
+ `hemline.themes.double`
+ `hemline.themes.dotted`
+ `hemline.themes.none`
from hemline.themes import double
frame = Frame(theme=double)
text = "This is some text"
frame.format(text)
Custom Theme
You can define a custom theme by instancing hemline.themes.Theme. If
you want to create a theme based on a single border character, you can use the
hemline.themes.factory for your convenience.
Colorized Frames
If you want the frame in a certain color, you can pass an instance of
hemline.colors.Color to the frame's constructor.
If you need more flexibility, you can subclass hemline.Frame, implement
a custom colorization function and inject it as class variable colorize. This
function must accept a string and a color parameter, and return the colorized
string.
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 Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hemline-1.0.0-py3-none-any.whl.
File metadata
- Download URL: hemline-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-48-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e009585e0c3a282f939b2cfe5eda1646f2812066cf2f0b626f0faf2c245a49cb
|
|
| MD5 |
33f1ab3c2ef81ae00b5cd3af909bcc28
|
|
| BLAKE2b-256 |
5a1cfd31d7aee3f52f94db7867825191ecf2784b50d658ede000f6880a85b0fd
|