[英]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 .我想总是在底部显示我的进度条,我的“for”循环环绕在 tqdm 周围,并且正在调用一些每次需要近 45 秒的函数,并为某些代码打印成功和失败消息。 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.
我得到了正确的进度条,但是对于每个循环,就像我的“for”循环迭代 5 次,那么每次调用都会显示 5 个进度条。 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.使用 tqdm.write() 代替打印函数效果很好。 Now I am getting correct output as I wanted to be Thanks to @acw1668
现在我得到了正确的输出,因为我想感谢@acw1668
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.