Skip to main content

Python library for creating progress bars

Project description

Interaction

Interaction is a Python package for creating nice and colourful progress bars using the map() and apply() method as well as for loops.

ProgressBar

To use a progress bar you need to initiate a ProgressBar object with the maximum progress amount (total) and call the show method of the object with the amount to update the progress bar.

from interaction import ProgressBar
from time import sleep

bar = ProgressBar(total=100)

for i in range(100):
  sleep(0.05)
  bar.show(amount=i+1)

You can also add your own text to the progress bar.

from interaction import ProgressBar
from time import sleep

bar = ProgressBar(total=100)
for i in range(100):
    sleep(0.05)
    bar.show(amount=i+1, text=f'working on {i}')

map

You can also use the ProgressBar's map method instead of Python's map method. The output is an iterable. As soon as you turn the iterable object into a list the progress bar will be displayed.

from interaction import ProgressBar
from time import sleep

list1 = list(range(100))

def wait_and_double(x, wait_time):
    sleep(wait_time)
    return x*2

# this will not make the progress bar appear
iterable2 = ProgressBar.map(
    function=lambda x: wait_and_double(x=x, wait_time=0.05), 
    iterable=list1
)

# this will make the progress bar appear
list2 = list(iterable2)

apply

ProgressBar also works with Panda's DataFrame and Series objects.

from interaction import ProgressBar
from time import sleep
from pandas import DataFrame

data = DataFrame({
    'name':['Arminius', 'Boudica', 'Alaric', 'Attila', 'Genseric'],
    'ethnicity': ['German', 'Celt', 'Goth', 'Hun', 'Vandal']
})

data['name_and_ethnicity'] = ProgressBar.apply(
    data=data, 
    function=lambda x: x['name']+' the '+x['ethnicity']
)

data['name_lower'] = ProgressBar.apply(
    series=data['name'], 
    function=lambda x: x.lower()
)

iterate

You can also use ProgressBar to for iterating over iterable objects, especially for loops.

from interaction import iterate

for i in iterate(range(100)):
    # do something
    pass

Project details


Release history Release notifications | RSS feed

This version

1.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

interaction-1.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

interaction-1.3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file interaction-1.3.tar.gz.

File metadata

  • Download URL: interaction-1.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for interaction-1.3.tar.gz
Algorithm Hash digest
SHA256 6e23e423f91856f109c69a3508cb7d2f08abcb404109f14fc7b1e1c7541bc9fa
MD5 eb9b924f1e9790d7f9913a770c5e3bea
BLAKE2b-256 7b966b66ea12f5a5a3af6bad58e92746b1f880cb27e2d8f3cbdaf7ff5e513d53

See more details on using hashes here.

File details

Details for the file interaction-1.3-py3-none-any.whl.

File metadata

  • Download URL: interaction-1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5

File hashes

Hashes for interaction-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3edcf4f027a4158c5971747dd44fc28c06868c47b2ed2215e62d4ae1cc0c2ca1
MD5 2a5ec7c4dc60a32d998dd28967f4fb10
BLAKE2b-256 ce9303a2763ee1b6c325f4c2440d88080adac44f1b5b09506a0aa37549da537f

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