我有这段代码:
stdscr = curses.initscr()
####Then I fill it with random letters
stdscr.refresh()
newwin=curses.newwin(10,20,5,5)
newwin.touchwin()
newwin.refresh()
####I want to delete newwin here so that if I write stdscr.refresh() newwin won't appear
stdscr.touchwin()
stdscr.refresh()
####And here it should appear as if no window was created.
答案 0 :(得分:7)
这应该可行:
import curses
def fillwin(w, c):
y, x = w.getmaxyx()
s = c * (x - 1)
for l in range(y):
w.addstr(l, 0, s)
def main(stdscr):
fillwin(stdscr, 'S')
stdscr.refresh()
stdscr.getch()
newwin=curses.newwin(10,20,5,5)
fillwin(newwin, 'w')
newwin.touchwin()
newwin.refresh()
newwin.getch()
del newwin
stdscr.touchwin()
stdscr.refresh()
stdscr.getch()
curses.wrapper(main)
用“S”填充终端;在任何一个keystoke,它用'w'填充窗口;在下一次击键时,它会移除窗口并再次显示stdscr,所以它再次全部为''';在下一次击键时,脚本结束,终端恢复正常。这不适合你吗?或者你真的想要一些不同的东西......?