Qin Yu, Apr 2020
ipywidgets are interactive HTML widgets for Jupyter notebooks, JupyterLab and the IPython kernel.
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextensionpip install tqdmIPython/Jupyter is supported via the tqdm.notebook submodule:
from tqdm.notebook import trange, tqdm
from time import sleep
for i in trange(3, desc='1st loop'):
for j in tqdm(range(100), desc='2nd loop'):
sleep(0.01)Some times the progress bar is showing 23/? in light blue, saying its currently on the 23rd item without the knowledge of a total.
This will give a light blue progress bar whose total task number is ?:
with os.scandir(path) as dir_img:
for entry in tqdm(path): # `tqdm.notebook.tqdm()` doesn't work with `os.scandir()` directly
if entry.name.endswith(".py") and entry.is_file():
passBy telling tqdm() the explicit form of iterator it is dealing with, a proper bar is shown. Just list() the os.scandir():
with os.scandir(path) as dir_img:
for entry in tqdm(list(path)): # `tqdm.notebook.tqdm()` doesn't work with `os.scandir()` directly
if entry.name.endswith(".py") and entry.is_file():
pass