def terminal_size():
"""
Return the number of terminal columns and rows, defaulting to
80x24 if the standard output is not a TTY.
NOTE THAT THIS ONLY WORKS ON UNIX.
"""
if sys.stdout.isatty():
# TODO: This only works on Unix.
rows, columns = [int(x) for x in
os.popen('stty size', 'r').read().split()]
else:
rows = 24
columns = 80
return rows, columns
评论列表
文章目录