8000 add a feature to make bar can stay at one line instead always newline · Issue #662 · tqdm/tqdm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add a feature to make bar can stay at one line instead always newline #662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
NewUserHa opened this issue Jan 24, 2019 · 16 comments
Closed
Assignees
Labels
help wanted 🙏 We need you (discussion or implementation) invalid ⛔ Not-an-issue or upstream (not-our-issue) p2-bug-warning ⚠ Visual output bad

Comments

@NewUserHa
Copy link

4.29.1
3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] win32
ipython

I have some info needs to be logged and printed. but tqdm will case:

from tqdm import tqdm
import time
for _ in tqdm(range(2)):
  print('a')
  time.sleep(0.5)

  0%|                                                                                            | 0/2 [00:00<?, ?it/s]a
 50%|██████████████████████████████████████████                                          | 1/2 [00:00<00:00,  1.99it/s]a
100%|█████████████████████████████████████████████████████████ ███████████████████████████| 2/2 [00:01<00:00,  1.99it/s]

use tqdm.write:

from tqdm import tqdm
import time
for _ in tqdm(range(2)):
  tqdm.write('a')
  time.sleep(0.5)

a
 50%|██████████████████████████████████████████                               
a
 50%|██████████████████████████████████████████                               
100%|█████████████████████████████████████████████████████████ ███████████████████████████| 2/2 [00:01<00:00,  1.99it/s]

is there a way to archeve:

a
a
 50%|██████████████████████████████████████████                               
100%|█████████████████████████████████████████████████████████ ███████████████████████████| 2/2 [00:01<00:00,  1.99it/s]

or even make there's only one bar last?
thanks

@casperdcl
Copy link
Member

looks like a windows issue #556, #200, #499, #454, #307...

you can try replacing tqdm(range(2)) -> tqdm(range(2), ascii=True)

@casperdcl
Copy link
Member

also try installing colorama

@casperdcl casperdcl self-assigned this Jan 24, 2019
@casperdcl casperdcl added question/docs ‽ Documentation clarification candidate p2-bug-warning ⚠ Visual output bad and removed p2-bug-warning ⚠ Visual output bad labels Jan 24, 2019
@NewUserHa
Copy link
Author
NewUserHa commented Jan 25, 2019

Requirement already satisfied: colorama in c:\program files\python37\lib\site-packages (0.3.9)

from tqdm import tqdm
import time
for _ in tqdm(range(2), ascii=True):
  print('a')
  time.sleep(0.5)
  0%|                                                                                            | 0/2 [00:00<?, ?it/s]a

 50%|##########################################                                          | 1/2 [00:00<00:00,  1.99it/s]a

100%|####################################################################################| 2/2 [00:01<00:00,  1.99it/s]

and the colns seems like detected more than the actual value, and made there's a empty newline between every bar
ps: the results I posted in my first comment also have this problem in console. but it's ok after copy-paste out

@NewUserHa
Copy link
Author

image
I haven't resized the window after opening

@casperdcl
Copy link
Member

if you manually set ncols=80 or similar, do you still get this issue?

@NewUserHa
Copy link
Author

image
NO

casperdcl added a commit that referenced this issue Jan 25, 2019
@casperdcl
Copy link
Member

does this fix your issue?

pip install -e git+https://github.com/tqdm/tqdm.git@win_fix#egg=tqdm

and then

from tqdm import tqdm
import time
for _ in tqdm(range(2)):
  tqdm.write('a')
  time.sleep(0.5)

@NewUserHa
Copy link
Author

image

@NewUserHa
Copy link
Author
NewUserHa commented Jan 26, 2019

image
did it work for you?

@casperdcl
Copy link
Member
casperdcl commented Jan 26, 2019

I think you need to use both ascii=True and tqdm.write():

from tqdm import tqdm
import time
for _ in tqdm(range(2), ascii=True):
  tqdm.write('a')
  time.sleep(0.5)

Let me know if the above works for the win_fix branch (pip install -e git+https://github.com/tqdm/tqdm.git@win_fix#egg=tqdm) and also for master (pip install -U tqdm)

@NewUserHa
Copy link
Author

winfix:
image

master just installed few second ago:
image
master also work for cmd and powershell. (but didn't do test with winfix.)

@NewUserHa
Copy link
Author
NewUserHa commented Jan 27, 2019

master:
image
can consider reduce default ncols detected on windows and fix above too?

can also fix the behavior with default print function?
OR
making tqdm.write can input numbers like print so we can use print=tqdm.write?

@casperdcl
Copy link
Member

duplicate of #454 #499 #556

@casperdcl casperdcl added p2-bug-warning ⚠ Visual output bad help wanted 🙏 We need you (discussion or implementation) invalid ⛔ Not-an-issue or upstream (not-our-issue) and removed question/docs ‽ Documentation clarification candidate labels May 9, 2019
@NewUserHa
Copy link
Author
NewUserHa commented Oct 9, 2019

what about make ascii and ncols default used on windows to avoid this issue at the beginning? @casperdcl
I just verified that 4.36.1 also has this issue

@casperdcl
Copy link
Member

yes, part of #815...

@NewUserHa
Copy link
Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted 🙏 We need you (discussion or implementation) invalid ⛔ Not-an-issue or upstream (not-our-issue) p2-bug-warning ⚠ Visual output bad
Projects
None yet
Development

No branches or pull requests

2 participants
0