どのように私はPythonで呪いのウィンドウを削除し、背景のウィンドウを復元するのですか?
質問
地獄-Oみんな、私は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.
解決
この、例えば、動作するはずます:
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