Helpful functions for python.
Project description
Statusbar for Python for/while
loops
Installation
pip install danpy
Installation from GitHub
git clone https://github.com/danhagen/danpy.git && cd danpy
pip install -r requirements.txt
pip install .
Example usage:
Initialize statusbar before running a for/while loop.
from danpy.sb import *
from time import sleep
SB = dsb()
N_loops = 10
for i in range(N_loops):
sleep(0.5)
SB.statusbar(i,N_loops,Title="Test Loop")
It is useful to either reset the statusbar instance. However, loops run in succession will automatically reset if the loops are of the same size.
from danpy.sb import *
from time import sleep
SB = dsb()
N_loops = 10
for j in range(3):
for i in range(N_loops):
sleep(0.5)
SB.statusbar(i,N_loops,Title="Testing Loop-D-Loops")
for i in range(N_loops):
sleep(0.5)
SB.statusbar(i,N_loops,Title="Test Another Loop")
Resetting Statusbar
from danpy.sb import *
from time import sleep
SB = dsb()
N_loops = 10
for i in range(N_loops):
sleep(0.5)
SB.statusbar(i,N_loops,Title="Testing One Loop")
SB.reset_dsb()
N_loops = 20
for i in range(N_loops):
sleep(0.5)
SB.statusbar(i,N_loops,Title="Test A Different Loop")
Using while
Loops
If using a while
loop, the statusbar will still update, but depending on the nature of the code in the loop, the extrapolation to determine time remaining may be off.
from danpy.sb import *
from time import sleep
SB = dsb()
count = 0
N_loops = 10
while count<=N_loops:
sleep(0.5)
SB.statusbar(count,N_loops,Title="Testing One Loop")
count+=1
Only compatible with while loops that utilize a count
metric where the loop continues while count<N_loops
. The "<" ensures that the statusbar terminates at 100%. If you use "<=" then the input to the statusbar will be SB.statusbar(i,N_loops+1,**kwargs)
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
danpy-0.0.5.tar.gz
(3.6 kB
view hashes)
Built Distribution
danpy-0.0.5-py3-none-any.whl
(3.9 kB
view hashes)