curses and terminal resize
janne halttunen
jhalttun at pp.htv.fi
Tue Jul 23 10:01:53 EDT 2002
Hello all,
I am writing a curses widget library. The trouble I am having is to
obtain new values for lines and columns in terminal after resize event.
I have a short program below that should demostrate the problem:
"""curses window resize test program. ctrl-c to exit"""
import curses
import signal
def main(w):
w.nodelay(1)
count=0
def handle(*args):
w.erase()
w.addstr(0,0, str(count)+str(w.getmaxyx()))
signal.signal(signal.SIGWINCH, handle)
handle() # to get the initial values
while 1:
count+=1
w.refresh()
if __name__=='__main__':
curses.wrapper(main)
# EOF
If you run this in a xterm, you will see that the screen dimesions
remain the same after every resize. I have tried calling curses.initscr
again, but to no avail. Also the curses.tigetnum for 'lines' and 'cols'
always return the same values.
$ python -V
Python 2.2
$ python -c 'import sys; print sys.platform'
linux-i386
Any help is appreciated,
janne
More information about the Python-list
mailing list