Skip to main content

Various printing utilities and helpers/extenders for the `rich` package.

Project description

printbuddies

Various printing utilities and helpers/extenders for the rich package.
Install with:

pip install printbuddies

print_in_place

'print_in_place' erases the current line in the terminal and then writes the value of the 'string' param to the terminal.

from printbuddies import print_in_place
import time
#This will print numbers 0-99 to the terminal with each digit overwriting the last.
for i in range(100):
    print_in_place(i)
    time.sleep(0.1)

Tag

The Tag class is essentially a wrapper to shorten using rich tags.
When a Tag is casted to a string it is formatted with surrounding square brackets and the o or off properties can be accessed to return the matching closing tag.

from printbuddies import Tag
p = Tag("pale_turquoise4")
c = Tag("cornflower_blue")
s = f"{p}This{p.o} {c}is{c.o} {p}a{p.o} {c}string"

is equivalent to

s = "[pale_turquoise4]This[/pale_turquoise4] [cornflower_blue]is[/cornflower_blue] [pale_turquoise4]a[/pale_turquoise4] [cornflower_blue]string"

The ColorMap class contains two Tag properties for each named color (except shades of grey, those only have a full name property): one that's the full name of the color and one that's an abbreviated name, for convenience.

This is useful for seeing color options using autocomplete:

The class also supports iterating over the tags as well as selecting random colors:


The Gradient class inherits from list and can be used to easily apply an arbitrary number of color sweeps across text:

The Progress, BarColumn, and TaskProgressColumn classes, as well as the track function are the same as the rich versions, just with different default colors, default columns, and additonal keyword arguments.
TimerColumn is a subclass of rich.progress.TimeRemainingColumn that displays {time_elapsed}<->{time_remaining} with a color gradient.

Default columns and colors of this version:

The Grid class is a customized implementation of a rich Table.
It can minimally be used by passing a list of dictionaries to the constructor and then passing the instance to rich.print or rich.console.Console().print.
(All dictionaries should have the same set of keys)

from printbuddies import Grid
from rich import print
print(Grid(list_of_dicts))

Being used to display a database schema:

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

printbuddies-2.1.2.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

printbuddies-2.1.2-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file printbuddies-2.1.2.tar.gz.

File metadata

  • Download URL: printbuddies-2.1.2.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for printbuddies-2.1.2.tar.gz
Algorithm Hash digest
SHA256 535957c1e31351fd060f32efe6bf23a5f4c2ba4016981bb944027847713ffa57
MD5 988acb438a7f31a34e62eea8c58fea0b
BLAKE2b-256 c35f41b52693b9c1e7ed510f96b40f675f716a3ce27b50f0e7f3259c5bfdd700

See more details on using hashes here.

Provenance

File details

Details for the file printbuddies-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: printbuddies-2.1.2-py3-none-any.whl
  • Upload date:
  • Size: 18.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for printbuddies-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a62fafd5af68e58ad7fa63f73b3d326f8d480b6b65b32f886468cecfe2fa8be4
MD5 cd288f6d1c40d446b837059a3450eee6
BLAKE2b-256 2e8f9525abd90436640b3af080be11f6fef3bc9661db0afb223d353fc53d9d82

See more details on using hashes here.

Provenance

Supported by

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