帮助编写诅咒程序的库
ezcurses的Python项目详细描述
用于帮助进行光标编程的库(与Python3.3+兼容)
安装
从项目根目录:
$ python setup.py install
用法
最简单的方法是修饰函数,并使用注入的scr参数:
from time import sleep from ezcurses import curse @curse def main(scr, message_string): w, h = scr.max_size() scr.write(message_string, pos=(w // 2, h // 2)) scr.refresh() sleep(1) if __name__ == '__main__': main('Hello world!')
也可以使用受诅咒的上下文管理器。 下面是带有背景、边框和颜色的窗口的示例:
from ezcurses import Cursed with Cursed() as scr: w, h = scr.max_size() win1 = scr.new_win(orig=(0, 0), size=(20, 20)) win2 = scr.new_win(orig=(20, 0), size=(20, 20)) win1.border() win2.border() win1.background('+', color='red') win2.background('.', color=('green', 'blue')) win1.refresh() win2.refresh() s = win1.getstr((1, 1), echo=True) win2.write(s, (1, 1), color=('red', 'black')) win2.refresh() win1.write('Press q to quit', (1, 1), color=('black', 'red')) while win1.getkey() != 'q': pass
发行说明
0.2.12: |
|
---|---|
0.2.11: |
|
0.2.10: |
|
0.2.9: |
|
0.2.8: |
|
0.2.7: |
|
0.2.6: |
|
0.2.5: |
|
0.2.4: |
|
0.2.3: |
|
0.2.2: |
|
0.2.1: |
|
0.2.0: |
|
0.1.2: |
|
0.1.1: |
|
0.1.0: |
|
0.0.1: |
|