Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Small, C++-based python library to display async animations, counters, and progress bars.

Build status pypi

Installation: pip install barkeep


  • Display a waiting animation with a message:

    import time
    import barkeep as bk
    
    anim = bk.Animation(message="Working")
    anim.show()
    time.sleep(10)  # do work
    anim.done()
  • Supports several styles:

    anim = bk.Animation(message="Working", style=bk.Earth)
  • Display a counter to monitor a numeric variable while waiting:

    c = bk.Counter(message="Reading lines", speed=1.0, speed_unit="line/s")
    c.show()
    for i in range(505):
        time.sleep(0.013)  # read & process line
        c += 1
    c.done()
  • Display a progress bar to monitor a numeric variable and measure its completion by comparing against a total:

    bar = bk.ProgressBar(message="Reading lines", speed=1.0, speed_unit="line/s", total=505)
    bar.show()
    for i in range(505):
        time.sleep(0.013)  # read & process line
        bar += 1
    bar.done()
  • Combine diplays using | operator to monitor multiple variables:

    import random
    
    sents = bk.ProgressBar(total=1010, message="Sents")
    toks = bk.Counter(message="Toks", speed_unit="tok/s", speed=1.0)
    bar = sents | toks
    bar.show()
    for i in range(1010):
        # do work
        time.sleep(0.013)
        sents += 1
        toks += 1 + random.randrange(5)
    bar.done()
  • Use "no tty" mode to, e.g., output to log files:

    bar = bk.ProgressBar(total=401, message="Sents", speed=1.0, interval=1.0, no_tty=True)
    bar.show()
    for i in range(401):
        time.sleep(0.013)
        bar += 1
    bar.done()

    no_tty achieves two things:

    • Change the delimiter from \r to \n to avoid wonky looking output in your log files.
    • Change the default interval to a minute to avoid overwhelming logs (in the example above, we set the interval ourselves explicitly).