Skip to content

Commit 23ebf76

Browse files
committed
fix multi-characters custom bar symbols
Signed-off-by: Stephen L. <[email protected]>
1 parent 2360e45 commit 23ebf76

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tqdm/_tqdm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,13 @@ def extract_symbols(s, start_tag, end_tag):
304304
# normal progress symbols
305305
else:
306306
bar_length, frac_bar_length = divmod(
307-
int(frac * N_BARS * len(c_symbols)), len(c_symbols))
307+
int((frac/len(c_symbols[-1])) * N_BARS * len(c_symbols)), len(c_symbols))
308308

309309
bar = c_symbols[-1] * bar_length # last symbol is always the filler
310310
frac_bar = c_symbols[frac_bar_length] if frac_bar_length \
311311
else ' '
312+
# update real bar length (if symbols > 1 char) for correct filler
313+
bar_length = bar_length * len(c_symbols[-1])
312314

313315
# ascii format
314316
elif ascii:
@@ -332,7 +334,7 @@ def extract_symbols(s, start_tag, end_tag):
332334
# whitespace padding
333335
if bar_length < N_BARS:
334336
full_bar = bar + frac_bar + \
335-
' ' * max(N_BARS - bar_length - 1, 0)
337+
' ' * max(N_BARS - bar_length - len(frac_bar), 0)
336338
else:
337339
full_bar = bar + \
338340
' ' * max(N_BARS - bar_length, 0)

0 commit comments

Comments
 (0)