rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.45k stars 205 forks source link

bar.text() breaks when inserting different lenght of strings #228

Closed sergargar closed 1 year ago

sergargar commented 1 year ago

The bar.text() breaks when inserting different length of strings:

Screenshot 2023-03-02 at 16 24 36

It should be ap-south-east-1

Screenshot 2023-03-02 at 16 24 41

It should be ap-south-1

rsalmei commented 1 year ago

It doesn't break, there isn't any bug in texts that I know of. Look:

https://user-images.githubusercontent.com/6652853/222478337-cacefa53-f316-4e67-b7d9-0aa5fa90e0c0.mov

Here is the code, if you'd like to try in your terminal:

with alive_bar(1000) as bar:
    for i in range(1000):
        time.sleep(.01)
        bar()
        if i // 100 % 2 == 0:
            bar.text = f'A long text, that could take your whole line! {i}'
        else:
            bar.text = f'short text {i}'
sergargar commented 1 year ago

In my case, I also use a dynamic bar.title, I think that is the issue.

rsalmei commented 1 year ago

Just for completeness, dynamic titles work too:

https://user-images.githubusercontent.com/6652853/222864167-504f33f6-b51c-4c46-8992-f36726cc3024.mov

rsalmei commented 1 year ago

And even both at the same time!!

https://user-images.githubusercontent.com/6652853/222864423-3feddab0-0ae7-43aa-9413-92ffe1155cdf.mov

That's it, man, there isn't any bug in these mechanisms.