Skip to content

Commit

Permalink
Merge pull request #5 from gojuukaze/dev
Browse files Browse the repository at this point in the history
修改缓冲区函数
  • Loading branch information
gojuukaze authored Oct 22, 2020
2 parents e82f564 + 944937e commit 10d6494
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/source/FAQ.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,12 @@ View的宽度有两种,``width``, ``real_width``
具体参照 https://github.com/gojuukaze/terminal_layout/blob/master/demo/demo6(get_width).py


屏幕闪烁
--------------------------------

输出的文本太大会出现界面闪烁的情况,这时要调大sys.stdout的缓冲区。具体情况见: https://github.com/gojuukaze/terminal_layout/issues/3

可通过 ``ctl.set_buffer_size()`` 函数调大缓冲区。(建议在draw之前调用)



2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="terminal_layout",
version="2.0.0",
version="2.0.1",
description="The project help you to quickly build layouts in terminal (命令行ui布局工具)",
long_description=open("README.rst").read(),

Expand Down
9 changes: 9 additions & 0 deletions terminal_layout/ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ def __init__(self, layout=None):
)
self.refresh_thread.daemon = True

def set_buffer_size(self, size):
"""
当输出的文本太大会出现界面闪烁的情况,这时要调大sys.stdout的缓冲区
(见 https://github.com/gojuukaze/terminal_layout/issues/3 )
建议在draw之前调用
"""
self.buffering = size
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', self.buffering, encoding='utf-8')

def is_stop(self):
return self._stop_flag

Expand Down

0 comments on commit 10d6494

Please sign in to comment.