-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
c1-quick 🕐Complexity lowComplexity lowp2-bug-warning ⚠Visual output badVisual output badto-merge ↰ImminentImminent
Milestone
Description
- I have visited the source website, and in particular
read the known issues - I have searched through the issue tracker for duplicates
- I have mentioned version numbers, operating system and environment
I have checked the issue tracker and there are some issues similar but none exactly like this and they are closed - #591
Issue
There seems to be some bad formatting when using colors and writing messages with tqdm.write
Is this expected behaviour or am I using the API incorrectly?
Thanks
Debug Info
>>> tqdm.__version__, sys.version, sys.platform
('4.31.1', '3.7.2 (v3.7.2:9a3ffc0492, Dec 24 2018, 02:44:43) \n[Clang 6.0 (clang-600.0.57)]', 'darwin')
Example Code
from tqdm import tqdm, trange
import time
read_bar_format = "{l_bar}%s{bar}%s{r_bar}" % (
'\033[31m', '\x1b[39m'
)
for i in trange(2):
tqdm.write('test1')
time.sleep(0.1)
for i in trange(2, bar_format=read_bar_format):
tqdm.write('test2')
time.sleep(0.1)
Output
See the bad formatting around test2
> python test.py
test1
test1
100%|████████████████████████████████████████████| 2/2 [00:00<00:00, 9.77it/s]
test2
test2
100%|████████████████████████████████████████████| 2/2 [00:00<00:00, 9.59it/s]
I have tried to debug the issue and it seem to be to do with the line below.
N_BARS = max(1, ncols - len(RE_ANSI.sub('', l_bar + r_bar)))
https://github.com/tqdm/tqdm/blob/master/tqdm/_tqdm.py#L423
Screenshot
Metadata
Metadata
Assignees
Labels
c1-quick 🕐Complexity lowComplexity lowp2-bug-warning ⚠Visual output badVisual output badto-merge ↰ImminentImminent