Comments (5)
That is intended behaviour to be honest :)
The reason for always requiring a formatstring is consistency in spacing. With an empty formatstring it would move the other stuff in the progressbar around.
You can work around it by using a space ' '
or an invisible character such as '\x00'
from python-progressbar.
@wolph I'm not sure I understand. Could you give an example where an empty-string result of ETA would "move the other stuff in the progress bar around"?
from python-progressbar.
Just take a look at this code:
import time
import progressbar
bar = progressbar.ProgressBar(widgets=[
progressbar.ETA(format_finished=' '),
' Some text here ',
progressbar.Bar(),
])
for i in bar(range(5)):
bar.update(i)
time.sleep(0.1)
time.sleep(1.00)
The output looks something like this:
ETA: 0:00:00 Some text here |######### |
ETA: 0:00:00 Some text here |################## |
ETA: 0:00:00 Some text here |############################ |
ETA: 0:00:00 Some text here |##################################### |
Some text here |############################################################|
As you can see, the text moves and the bar becomes much wider suddenly. That can be a bit confusing :)
from python-progressbar.
I see.
However, this also happens when setting format_finished-' '
which you suggested previously.
import progressbar
for value in progressbar.progressbar(
[1],
widgets=[
"Foo",
progressbar.ETA(
format_finished=" ",
),
"Bar",
],
):
print()
FooETA: --:--:--Bar
Foo Bar
Similarly, the invisible character you suggested also does not preserve ETA's output length (format_finished="\x00"
):
FooETA: --:--:--Bar
FooBar
This behaviour may look subpar, but that's a subjective notion. Some users may want to have it that way, some may not.
If those two options you suggested don't preserve the output length of ETA, why should explicitly setting format_string=""
?
from python-progressbar.
Oops... didn't notice your reply.
It actually does work in your example, in both cases :)
The reason that it doesn't appear to work is because you're not seeing the format_finished
here but the format_not_started
. The progressbar overwrites the current line and with the print()
statement you're creating a new line so the old line won't be overwritten.
If you replace the print()
with pass
you'll see the proper output
If you want to use print statements in your code I would suggest enabling output redirection: https://github.com/wolph/python-progressbar#combining-progressbars-with-print-output
from python-progressbar.
Related Issues (20)
- Multi {threading/processing} support HOT 51
- FormatCustomText not updated HOT 2
- Question: best way to have multiple counters HOT 2
- Question: multiprocessing, logging and progressbar HOT 3
- ValueError: Value 40 is out of range, should be between 0 and 39 HOT 1
- Is there a way to wrap the progress bar output? HOT 2
- Timer and AdaptiveETA, possibly other time widgets print incorrect output when used with format kwarg HOT 1
- Is there a way to have multiple concurrent and independent progress bars? HOT 7
- progressbar suddenly throwing 'function' object has no attribute 'ProgressBar' HOT 2
- Not sure how to go about doing this HOT 4
- outdatated progress bar? HOT 1
- Preventing regular ETA update or replacing it HOT 8
- Replace the moving average algorithm
- Not an issue but an idea HOT 4
- MultiBar does not work if any of the node has an empty string as key HOT 1
- Colored markers HOT 7
- `cli-name` executable refers to non-existing Python module HOT 4
- 4.3.0: Windows OS: TypeError: '_fields_' must be a sequence of (name, C type) pairs HOT 3
- Progressbar update creates multiple lines HOT 19
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-progressbar.