[Tutor] curses delwin functionality?

Bernd Prager bernd at prager.ws
Thu Dec 29 16:31:10 CET 2005


Hi,

I'm trying to get my hands on some curses experiences in Python.

The examples I found don't really tell me how to get rid of subwindows and
restore the underlying window again. Is there something that replaces the
curses functionality "delwin"?
Thanks for any help!
Here's my example:

#!/usr/bin/python
import sys, curses

def sub(scrn):
    s = curses.newwin(4, 30, 1, 1)
    s.erase()
    s.box()
    s.addstr(1, 1, "sub window")
    s.refresh()
    s.getch()
    # curses.delwin(s) <-- that doesn't exist :-/
    scrn.refresh()

def main(scrn):
    scrn = curses.initscr()
    curses.curs_set(0)                  # turn cursor off
    scrn.erase()
    scrn.addstr(2, 2, "press <F1> to continue, <F12> to quit");
    while 1:
        c = scrn.getch()
        if c == curses.KEY_F12: sys.exit()
        elif c == curses.KEY_F1: sub(scrn)

# main loop
if __name__ == '__main__':
    curses.wrapper(main)
    sys.exit()




More information about the Tutor mailing list