Skip to main content

Add color highlights, load bars, progress displays and style to your python scripts and shell sessions

Project description

Add text color highlights, load bars, progress displays and style to your python scripts and shell sessions

Collpy Gist

Applications

  • Highlight

  • special texts

  • errors

  • Create

  • Custom buttons or list bullet styles

  • Progress bars

    • Multi-styled loading bars

    • Percentage progress display

    • Spinner progress display

    • Random load bar

    • Download bar

Usage

To use, install package using pip

$ pip3 install collpy

Using Progress bars

Progress bars are used to tell how far or how long a process has gone or taken and how much is left to be done

It highlighs the lenght of the total procress and the time take to complete

Progress bars are best used when a user wants to iterate over a number of values and perform actions on those values while taken note of the average time elapsed and getting an idea of the time left for a process to reach completion.

Import package into python script or shell environment

from collpy import *
# or single imports
from collpy import Load_bar

# Using a custom load bar

# The lenght indicates the size of the fullbar or the number of
# single bars
loadbar = Load_bar(name="Processing...", length=20, style='$')
"""
The load bar can be loaded with the parameters absent
This makes the Load_bar use its default values
name = Loading...
length = 20
style = #

i.e
"""
loadbar = Load_bar()

# to iterate over an iterable, it is best if its length
# is a multiple of the the length of the bar
# For instance if we have a list of 30 items
# we could do
loadbar = Load_bar(length=10) # or 15 as the case may be

# to iterate over the list
# say

lst = [i for i in <whatever>]
# or
string = 'some long string to be worked on'
# or
val = 100

# we do
for i in loadbar.iter(lst): # or string or val
    # do some work on i

The same method applies for the following But here, the styles are fixed and can’t be changed

darkbar = Dark_bar()
circlebar = Circle_bar()
squarebar = Square_bar()

Using the random bar

randombar = Random_bar()
# the name paramenter can be changed or left as default
randombar = Random_bar(name='Downloading... ')

# to use, call the iter method with the iterable
for i in random.iter(val):
    # do some work on (i)

Using the Spinner and percent

spinner = Spinner()
# the name paramenter can be changed or left as default
spinner = Spinner(name='Authenticating... ')

# to use, call the iter method with the iterable
# support for a next() method will be available in future versions
for i in spinner.iter(val):
    # do some work on (i)

# the same process works for percent
percent = Percent()

Support for a next() method for progress bars will be available in future versions

Adding Highlights

Note: Highlights are best used with the pring function

Creating a botton or bullet style

Available botton states [‘x’,’=’,’+’,’*’,’~’,’$’,’#’,’@’,’ ‘,’-‘]

Available colors [‘red’,’green’,’orange’,’blue’,’purple’,’lightblue’,’cyan’]

# to add button
# the ind parameter represents the index of the botton state on the list
# of available botton states. Remember indexing in python starts at 0
# default index is zero, default color is red
# default outer is True

# outer (a boolean) determines if the botton should have an outer shell
# or not i.e '[x]' or 'x'

but = button(ind=2,color='lightblue')
message = 'text text text'
print(but + message)

Changing text color and background

CHANGING TEXT COLOR

When text color is to be changes, the text to be printed out should be printed the the colpy cprint(txt=text,color=’purple’) method

This prints out the text with the intended color

# An example
# for a list of values to be printed out
for i in list:
    cprint(txt=i, color='orange')

This prints out the test in the specified color

CHANGING BACKGROUND

The background of a text can be changes to highligh parts of texts, show errors among other things

Available colors [‘black’,’red’,’green’,’orange’,’blue’,’purple’,’lightblue’,’cyan’]

# An example
err = 'List index out of range'
error = highlight(txt=err,color='red')
print('IndexError: ' + error + '....')

Note

  • kindly share with friends :smiley:

  • Thank you for using :smile:

  • If there is any problem, you can open an issue :grey_question:

  • Leave us a star :star:

Contributor(s)

[@BlankGodd](https://github.com/BlankGodd)

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

collpy-0.0.4.tar.gz (279.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

collpy-0.0.4-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file collpy-0.0.4.tar.gz.

File metadata

  • Download URL: collpy-0.0.4.tar.gz
  • Upload date:
  • Size: 279.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.2

File hashes

Hashes for collpy-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e798a4638d5eea304372aaf87ba56c72c7190063886b5b85b9c6682bb4713a31
MD5 e23948150c156a7631d0e3780c50f614
BLAKE2b-256 dd32e9983bc1faf3ee2f73187870807a6f5dbe1b96a1a8fda039f9f4e35ba583

See more details on using hashes here.

File details

Details for the file collpy-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: collpy-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.2

File hashes

Hashes for collpy-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 8fd98c8dee1a0fb898ed3a58a1ec9cc0b73cca37b1b9ad1157990ea716c4abca
MD5 974dc089939f8ddeb5f1f298fd86a8c4
BLAKE2b-256 40b36020179fea56664ff9602546b90865ddef9a61275ca17a35fbb2a68f4709

See more details on using hashes here.

Supported by

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