Skip to main content

Handful of utilities to do printing tricks to the terminal.

Project description

printbuddies

A few utilities to do terminal printing tricks.
Install with:

pip install printbuddies

Contains one class and three functions: ProgBar, print_in_place, ticker, and clear.

ProgBar is a self-incrementing, dynamically sized progress bar.
The progress counter and completion values can be manually overriden if desired.
The width of the progress bar is set according to a ratio of the terminal width so it will be resized automatically if the terminal width is changed.
The display function has a 'return_object' parameter, allowing ProgBar to be used in comprehensions.
Basic usage:

from printbuddies import ProgBar
total = 100
bar = ProgBar(total=total-1)
for _ in range(total):
    bar.display()
bar.reset()
my_list = [bar.display(return_object=i) for i in range(total)]

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)

ticker prints a list of strings to the terminal with empty lines above and below such that previous text in the terminal is no longer visible.
Visually, It functions as a multi-line version of print_in_place.
from printbuddies import ticker
import time
#This will produce visually the same output as the above example
for i in range(100):
    ticker([i])
    time.sleep(0.1)

A call to clear() simply clears the current line from the terminal.

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

Uploaded Source

Built Distribution

printbuddies-1.0.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for printbuddies-1.0.1.tar.gz
Algorithm Hash digest
SHA256 195febbb27d1dfaeab171b7b48a54da692b044db274431017543bf6f0dc22bf8
MD5 f2e82e29d613c22ad8854a44e9890364
BLAKE2b-256 f1a0e495058a58573a7c326e73626b686f3dcfe60612c8386b30dd670c3efd76

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for printbuddies-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e19b878719ba8609e759e0191ab38d215e481312de1cbb3f49d9262d3af5191
MD5 c466bf382e5001f6471493d119f968af
BLAKE2b-256 53f80612297f1798f2ec197bdc62e17fb4ed2717cff8133760a52781b96386a9

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