Search code examples
pythonresizecurses

Python Curses Handling Window (Terminal) Resize


This is two questions really:

  • how do I resize a curses window, and
  • how do I deal with a terminal resize in curses?

Is it possible to know when a window has changed size?

I really can't find any good doc, not even covered on http://docs.python.org/library/curses.html


Solution

  • Terminal resize event will result in the curses.KEY_RESIZE key code. Therefore you can handle terminal resize as part of a standard main loop in a curses program, waiting for input with getch.