Progress Bar displayed in Notion like tqdm for Python using notion-py
.
notion-tqdm
inherits from tqdm, so it can be run in the same way as tqdm.
pip install git+https://github.com/shunyooo/notion-tqdm
-
Get Notion's Token for reference here
-
Duplicate this page in your own workspace and get the table link. (Note that it is a table link, not a page link.)
from notion_tqdm import notion_tqdm
from time import sleep
# Configure
token_v2 = '<token_v2>'
table_url = '<table_url>'
notion_email = '<notion_email>' # For multi-account users
notion_tqdm.set_config(token_v2, table_url, email=notion_email, timezone='Asia/Tokyo')
# Run Iterate
for i in notion_tqdm(range(100), desc='Processing'):
sleep(1)
print(i)
A row representing the progress should be added to the table as shown below.
from tqdm.auto import tqdm as tqdm_auto
from time import sleep
# Nest tqdm
tqdm = lambda *args, **kwags: tqdm_auto(notion_tqdm(*args, **kwags))
for i in tqdm(range(100)):
sleep(1)
print(i)
# After this setting, the value will be added to the column by default.
# The `machine` column must be added to the table beforehand.
notion_tqdm.set_common_props(machine='Jupyter1')
with notion_tqdm(range(50), desc='process') as pbar:
for i in pbar:
# ... some process ...
# The `precision`, `highparam` column must be
# added to the table beforehand.
pbar.update_props(precision=precision, highparam=highparam)
with notion_tqdm(range(500), desc='add text test') as pbar:
for i in pbar:
sleep(1)
pbar.add_text(f'text: {i}')
With Notion's timeline view, you can visualize the execution time of the progress.