标签:UI mina output jupyter write style logs yield sci
在PowerShell中隐藏光标
在pip的源码C:\Python36\Lib\site-packages\pip\utils\ui.py中发现了:
1 @contextlib.contextmanager 2 def hidden_cursor(file): 3 # The Windows terminal does not support the hide/show cursor ANSI codes, 4 # even via colorama. So don‘t even try. 5 if WINDOWS: 6 yield 7 # We don‘t want to clutter the output with control characters if we‘re 8 # writing to a file, or if the user is running with --quiet. 9 # See https://github.com/pypa/pip/issues/3418 10 elif not file.isatty() or logger.getEffectiveLevel() > logging.INFO: 11 yield 12 else: 13 file.write(HIDE_CURSOR) 14 try: 15 yield 16 finally: 17 file.write(SHOW_CURSOR)
本来都打算放弃了, 第二天在windows上PowerShell中一试居然可以
具体HIDE_CURSOR的代码在C:\Python36\Lib\site-packages\pip\_vendor\progress\helpers.py文件中
1 HIDE_CURSOR = ‘\x1b[?25l‘ 2 SHOW_CURSOR = ‘\x1b[?25h‘
跟进度条的斗争, 从sys.stdout.write()和sys.stdout.flush(), 到progressbar2, 再到tqdm, 再到之后因为tqdm在jupyter notebook中好看, 于是折腾anaconda, 最终试着研究tqdm源码, 发现ascii参数, 再到研究pip源码,着实学到不少, 不过像本少这种门外少年, 还是需要时间慢慢来, 才能接受看源码的设定. 苦笑...
最后附上个人定制进度...称不上条了....
标签:UI mina output jupyter write style logs yield sci
原文地址:http://www.cnblogs.com/sigai/p/7741806.html