简体   繁体   English

如何使用 tkinter python 在控制台底部显示进度条

[英]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.

相关问题 如何使用python在tkinter中添加进度条 - How to add a progress bar in tkinter using python 使用 python 安装 PIP 依赖项(使用操作系统或子进程执行 CLI)并在 tkinter 中显示进度条 - Install PIP dependencies using python (using OS or Subprocess for executing CLI) and show progress in progress bar in tkinter Python:tkinter 进度条未更新 - Python: tkinter progress bar not updated 使用 Tkinter 的圆形进度条? - Circular progress bar using Tkinter? 如何在Python中显示带有进度条的对话框 - How to show a dialog pane with a progress bar in Python Python Tkinter:使用多线程时进度栏出现故障 - Python Tkinter: Progress bar malfunction when using multi-threading 如何在python中的tkinter的消息框中放置进度栏? - How do I put a progress bar in a messagebox in tkinter in python? 在tkinter中的系统调用期间显示进度栏 - Show Progress Bar during a system call in tkinter 如何在 python 中实现 tkinter 进度条,用户可以在相同的 position 中暂停和重新启动进度条? - How to implement a tkinter progress bar in python where the user can pause and restart the progress bar at the same position it was stopped? 使用 Python 在控制台中本地文件上传进度条 - Local file upload progress bar in console using Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM