简体   繁体   中英

How to show progress bar at bottom of console using tkinter python

I want to show my progress bar always in the bottom , my "for" loop is wrapped around tqdm and is calling some function which takes nearly 45s everytime and prints success and failure message for some code . I am getting the progress bar correctely but for every loop , like if my "for" loop is iterating 5 times then 5 progress bar is showing for every call. My console looks like this -

  0%|                                                                                                            | 0/4 [00:00<?, ?it/s]
Processing ---ASHISH KUMAR SINGH ---
ASHISH KUMAR SINGH is registered already
Failure --- ASHISH KUMAR SINGH --- due to Message: no such window: window was already closed
  (Session info: chrome=86.0.4240.111)

 25%|█████████████████████████                                                                           | 1/4 [00:16<00:49, 16.52s/it]
Processing ---ANJANI LAL ---
ANJANI LAL is registered already
Failure --- ANJANI LAL --- due to Message: no such window: window was already closed
  (Session info: chrome=86.0.4240.111)

 50%|██████████████████████████████████████████████████                                                  | 2/4 [00:25<00:28, 14.19s/it]
Processing ---SORAV SAINI ---
SORAV SAINI is registered already
Failure --- SORAV SAINI --- due to Message: no such window: target window already closed
from unknown error: web view not found
  (Session info: chrome=86.0.4240.111)

 75%|███████████████████████████████████████████████████████████████████████████

How can i just update the bar in the bottom, for example i Want a single bar to remains in the bottom and dynamically updating for every loop like this -->

Processing ---ANJANI LAL ---
ANJANI LAL is registered already
Failure --- ANJANI LAL --- due to Message: no such window: window was already closed
  (Session info: chrome=86.0.4240.111)

Processing ---SORAV SAINI ---
SORAV SAINI is registered already
Failure --- SORAV SAINI --- due to Message: no such window: target window already closed
from unknown error: web view not found
  (Session info: chrome=86.0.4240.111)
100%|████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4

I want this bar to remains in bottom and updating dynamically How can i achieve this ?? Thanks

Using tqdm.write() instead of print functions worked well. Now I am getting correct output as I wanted to be Thanks to @acw1668

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM