【发布时间】:2017-02-14 11:05:14
【问题描述】:
是否可以在 colorama 中使用诅咒?这是我的代码,它打印转义序列:
from curses import wrapper
import colorama
STYLE = colorama.Fore.GREEN + colorama.Back.BLUE
TITLE = STYLE + 'Current terminal size:'
HEIGHT_STRING = STYLE + 'Screen height: {}\n'
WIDTH_STRING = STYLE + 'Screen width: {}\n'
STR_LEN = 18
def main(stdscr):
colorama.init()
stdscr.clear()
height, width = stdscr.getmaxyx()
y = height//2 - 2
x = width//2 - STR_LEN//2
stdscr.addstr(y - 2, x, TITLE)
stdscr.addstr(y, x, HEIGHT_STRING.format(height))
stdscr.addstr(y + 1, x, WIDTH_STRING.format(width))
stdscr.refresh()
stdscr.getkey(y + 2, x)
if __name__ == '__main__':
wrapper(main)
我知道 curses 不能在 Windows 上使用,只是想知道这是否可能
【问题讨论】:
标签: python python-curses colorama