Skip to main content

Print Box

Class with functions to delimit a box on screen (With a border or not) and print strictly inside the created box, with scroll to the new lines.

Prerequisites

Developed and tested in Linux and Python 3.6

Installing

pip3 install ebx_printbox

or from source:

python3 -m pip install [your_path]/ebx_printbox/

Functions

pyBox

pyBox(x, y, x2, y2, border=False, clear_screen=False):

Description: Create a instance of a box, with sizes, border and information if will perform a clear screen

Parameter Description
x: Line of box beginning on screen
y: Column of box beginning on screen
x2: Line of box end on screen
y2: Column of box end on screen
border: Draw a border (will reduce 2 lines and 2 columns of useful box)
clear_screen: Clear screen before draw a box

Return: Box object


box_clear

box_clear()

Description: Clear buffer. Necessary on new print calls

Return: None


box_print

box_print(txt_String, new_Line=True):

Description: Print anything on a delimited box created by pyBox()

Parameter Description
txt_String: Text to print (accept Text_Color contants)
new_Line: Print on new line (True) or over last line (False)

Return: None

Examples of use

example1.py

import ebx_printbox
from time import sleep

# Box(Line:16, Column: 1 to Line: 52, Column: 120 - No Border, No Clear Screen)
obj_Box1 = ebx_printbox.pyBox(16, 1, 52, 120, False, True)
obj_Box1.create_box()

for i in range(501):
    obj_Box1.box_print('Text: ' + str(
        i) + ' Lorem ipsum dolor sit amet, ad suas sale eam, falli suavitate corrumpit an sit. Latine viderer ex vis. '
             'Ex maiorum fuisset aliquando vix, in cum dicant gloriatur. Ei elit argumentum cum, quod blandit an eum.')
    sleep(1)  # Time in seconds.

Results:

asciicast


example2.py

import ebx_printbox
from time import sleep


class text_color:
    fg_Black = "\033[0;30m"
    fg_Red = "\033[0;31m"
    fg_Green = "\033[0;32m"
    fg_Yellow = "\033[0;33m"
    fg_Blue = "\033[0;34m"
    fg_Magenta = "\033[0;35m"
    fg_Cyan = "\033[0;36m"
    fg_White = "\033[0;37m"
    fg_Bright_Black = "\033[0;90m"
    fg_Bright_Red = "\033[0;91m"
    fg_Bright_Green = "\033[0;92m"
    fg_Bright_Yellow = "\033[0;93m"
    fg_Bright_Blue = "\033[0;94m"
    fg_Bright_Magenta = "\033[0;95m"
    fg_Bright_Cyan = "\033[0;96m"
    fg_Bright_White = "\033[0;97m"
    text_reverse = "\033[;7m"
    text_underline = "\033[1;4m"
    text_reset_underline = "\033[1;24m"
    text_reset = "\033[0;0m"
    bg_Black = "\033[1;40m"
    bg_Red = "\033[1;41m"
    bg_Green = "\033[1;42m"
    bg_Yellow = "\033[1;43m"
    bg_Blue = "\033[1;44m"
    bg_Magenta = "\033[1;45m"
    bg_Cyan = "\033[1;46m"
    bg_White = "\033[1;47m"
    bg_Bright_Black = "\033[1;100m"
    bg_Bright_Red = "\033[1;101m"
    bg_Bright_Green = "\033[1;102m"
    bg_Bright_Yellow = "\033[1;103m"
    bg_Bright_Blue = "\033[1;104m"
    bg_Bright_Magenta = "\033[1;105m"
    bg_Bright_Cyan = "\033[1;106m"
    bg_Bright_White = "\033[1;107m"


obj_Box1 = ebx_printbox.pyBox(16, 1, 20, 120, False, True)
obj_Box1.create_box()

num_IP = dict()
num_IP['DC'] = 'dc-1'
num_IP['IP'] = '192.168.1.1'

for i in range(15):
    obj_Box1.box_print(
        '[' + text_color.fg_Bright_Red + 'BACKUPING ' + text_color.text_reset + '] JVM on %s  -  %s \r' % (
            '192.168.1.' + str(i), num_IP['IP']), True)
    sleep(1)  # Time in seconds.
    obj_Box1.box_print(
        '[' + text_color.fg_Bright_Red + 'CHANGING  ' + text_color.text_reset + '] JVM on %s  -  %s \r' % (
            '192.168.1.' + str(i), num_IP['IP']), False)
    sleep(1)  # Time in seconds.
    obj_Box1.box_print(
        '[' + text_color.fg_Bright_Red + 'APPLYING  ' + text_color.text_reset + '] JVM on %s  -  %s \r' % (
            '192.168.1.' + str(i), num_IP['IP']), False)
    sleep(1)  # Time in seconds.
    obj_Box1.box_print(
        '[' + text_color.fg_Green + 'RESTARTING' + text_color.text_reset + '] JVM on %s  -  %s \r' % (
            '192.168.1.' + str(i), num_IP['IP']), False)
    sleep(1)  # Time in seconds.


Results:

asciicast


##Multiprocessing example3.py - 2 Boxes with multiprocessing

import ebx_printbox
from multiprocessing import Process
from time import sleep
import os

lst_ObjBox = []
lst_Process = []

# Box(Line:30, Column: 10 to Line: 40, Column: 100 - No Border, Clear Screen)
lst_ObjBox.append(ebx_printbox.pyBox(30, 10, 40, 100, False, True))
lst_ObjBox[0].create_box()

# Box(Line:10, Column: 70 to  Line: 25, Column: 120 - With Border, No Clear Screen)
lst_ObjBox.append(ebx_printbox.pyBox(10, 70, 25, 120, True, False))
lst_ObjBox[1].create_box()


def multi_Box(int_Box):
    for i in range(50):
        lst_ObjBox[int_Box].box_print('Texto: ' + str(i) + ' - Process: ' + str(
            os.getpid()) + ' Lorem ipsum dolor sit amet, ad suas sale eam, falli suavitate corrumpit an sit. Latine '
                           'viderer ex vis. Ex maiorum fuisset aliquando vix, in cum dicant gloriatur. Ei elit '
                           'argumentum cum, quod blandit an eum.')
        sleep(1)  # Time in seconds.


for index in range(2):
    obj_Process = Process(target=multi_Box, args=(index,))
    lst_Process.append(obj_Process)
    obj_Process.start()

# Exit the completed processes
for obj_Process in lst_Process:
    obj_Process.join()


###Results:

asciicast


Versioning

=======================================================================================
== Log Changes:
== Date:            2021-05-13
== Author:          Fausto Branco
== Version:         1.0.0
== Description:     Initial Version
=======================================================================================

License

Metadata

Release files for ebx-printbox 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ebx-printbox 1.0.2
File Size Uploaded Provenance Actions
ebx_printbox-1.0.2.tar.gz 19.1 kB Without provenance Details for ebx_printbox-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ebx-printbox 1.0.2
File Interpreter ABI Platform Actions
ebx_printbox-1.0.2-py3-none-any.whl Python 3 none any Details for ebx_printbox-1.0.2-py3-none-any.whl

Total release size: 35.6 kB

Release files / ebx_printbox-1.0.2.tar.gz

Download URL ebx_printbox-1.0.2.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9a6f88cc70d00ce5362ad7d152ea6d2167d317897c01a84a894d979321ee483e
BLAKE2b-256 checksum
How to use checksums
6725b34e283c25610a9b11f27d2e818584049d846e28f6053c1f405b8593eb54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8

Release files / ebx_printbox-1.0.2-py3-none-any.whl

Download URL ebx_printbox-1.0.2-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4090e9335333f39599526b0abd3bbba9a742d432b8a8a40ffb5a66cbb721645
BLAKE2b-256 checksum
How to use checksums
af3124bf6f32ce1f100cda8ea9d975783f993323745b1d602130153ad67fbd2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.8

Security for ebx-printbox 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page