-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Hello,
I have an improvement suggestion, and a brief search didn't turn up anything similar. I like the efficiency of tqdm when reporting loop completion, but sometimes i don't want to run my script in console mode. I may want to run it inside a PyQT window, for example, and have tqdm update a progress bar. I couldn't think of any way to do this from tqdm.
Rather than writing a specific PyQT wrapper, i was thinking it would be better if a function was passed to tqdm which would be called every refresh interval. tqdm would pass either a list or tuple to this function, containing % done, the progress bar text, it/s, etc. Then the function would pick whatever it needs from it and act accordingly.
for i in tqdm(list_to_process, call_f=update_progress):
# do stuff
def update_progress(tqdm_list):
main_window.progress_bar.setValue(tqdm_list[0])
One other thing to consider is that, due to the possible complexity of the called function, the call to it may be done at a lower frequency than the console output refresh rate.