如何在python删除诅咒窗口和恢复窗口背景?
题
地狱邻家伙,我工作的蟒蛇诅咒,我有我的initscr的(初始窗口),我创造了一些新的窗口重叠的话,我想知道我是否可以删除这些窗口和恢复标准屏幕而无需填充它。有没有办法?我也可以问,如果有人能告诉我一个窗口,子窗口,垫和垫子之间的区别。
我有这样的代码:
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.
解决方案
此,e.g,应该工作:
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上,所以它再次全的“;在一个按键,脚本端部和终端恢复到正常的。这不是为你工作?还是你真正想要的东西不同...?
不隶属于 StackOverflow