Skip to content

Commit 14a872d

Browse files
authored
Update tqdm_progress_bar.py
1 parent e5ab00b commit 14a872d

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

tqdm_progress_bar.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
from tqdm import tqdm
2-
from time import sleep
3-
4-
no_of_files = 5 #example
5-
obj = tqdm(range(no_of_files))
6-
for i in obj:
7-
obj.set_description(f'File uploading {i+1}:')
8-
sleep(1)
1+
"""In this example, we will see how to code a progress bar for file upload using tqdm python module. Feel free to use it in your own way.
2+
3+
For more information, you may refer this docuentation - https://tqdm.github.io/
4+
5+
"""
6+
7+
from tqdm import tqdm # Importing tqdm module
8+
from time import sleep # We are importing sleep() from time module to enter delay just for this example.
9+
10+
no_of_files = 5 # Example - 5 files to upload
11+
12+
""" Creating a TQDM object so that we can use it later to customize the progress bar. This line will loop through the given range i.e. number of files in this case """
13+
14+
obj = tqdm(range(no_of_files))
15+
16+
for i in obj: #iterating through object range to start the progress bar
17+
obj.set_description(f'File uploading {i+1}:')
18+
sleep(1) # adding manual delay. This can be skipped for real example.

0 commit comments

Comments
 (0)