Closed max-bold closed 2 years ago
In your loop, the variable i
will never reach the intended 100
. So the progress was will never reach the end. Modify the script to output.update_progress(i + 1, 100)
In your loop, the variable
i
will never reach the intended100
. So the progress was will never reach the end. Modify the script tooutput.update_progress(i + 1, 100)
Thanks a lot! You're right. It's my mistake.
But what about the main issue? That progress bar is updated only when some output is made?
when you are looping very fast, the UI thread doesn't get a chance to update the progress bar. Adding a print statement in there would help.
If you only need a progress bar without any output you can use the progress bar that snaps on top of the window:
Interesting note: if we print('')
nothing is printed (no empty line) but the progress bar is updated. Now the code looks like:
output = script.get_output()
print('hello')
for i in range(100):
output.update_progress(i, 99)
sleep(0.1)
print('')
print('End')
Thanks a lot @eirannejad !
output.update_progress(i, max)
doesn update output window so progress is updated only when some output is madeThis is a sample code:
If last
print(i)
is commented it's expected to see'hello'
in output window and moving progress bar. But in fact we see only a blank output window until the loop ends. And only after that we see'hello'
and 99% progress bar (and why 99? not 100?).