Skip to main content

Allows the ability to rewrite multiple lines via carriage returns.

Project description

multicarriage

PyPI - Version Pepy Total Downlods PyPI - Python Version GitHub repo size

A Python module designed for writing and updating text on multiple lines using the the carriage return.

multicarriage-preview

Usage

Previewing Package

$ python3 -m multicarriage.demo

Importing Package

import multicarriage

Creating Newlines

Creating newlines prevents text from being overwritten.

multicarriage.MultiCarriage.create_newline(2)

Writing to Screen

multicarriage.MultiCarriage.write("first text", 2, clearline=True)
multicarriage.MultiCarriage.write("second text", 1, clearline=True)

Setting the clearline parameter to true will erase the current line of which the cursor is on, assuring there will be no overwritten text.

Example of Real Script Usage

Example script that will write and update 3 lines at once.

# example of auto updating epoch and datetime
import multicarriage
import time
import datetime

# creating newlines to avoid overwriting current text
multicarriage.MultiCarriage.create_newline(3)
while True:
    try:
        timestamp = time.time()
        date = datetime.datetime.fromtimestamp(timestamp)
        multicarriage.MultiCarriage.write(f"epoch: {timestamp}", 3, clearline=True, flushtxt=True)
        multicarriage.MultiCarriage.write(f"epoch (s): {timestamp//1}", 2, clearline=True, flushtxt=True)
        multicarriage.MultiCarriage.write(f"datetime string: {date}", 1, clearline=True, flushtxt=True)
        time.sleep(1/10)
    except KeyboardInterrupt:
        raise SystemExit(0)

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

multicarriage-1.1.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

multicarriage-1.1-py3-none-any.whl (4.1 kB view hashes)

Uploaded Python 3

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